diff --git a/tests/test_infected_asyncio.py b/tests/test_infected_asyncio.py index 8fa6eb5..cb0a400 100644 --- a/tests/test_infected_asyncio.py +++ b/tests/test_infected_asyncio.py @@ -256,8 +256,13 @@ async def stream_from_aio( if fan_out: # start second task that get's the same stream value set. async with ( - trio.open_nursery() as n, + + # NOTE: this has to come first to avoid + # the channel being closed before the nursery + # tasks are joined.. chan.subscribe() as br, + + trio.open_nursery() as n, ): n.start_soon(consume, br) await consume(chan)