From 333fad8819fd1d9d6b4e89f2c2dbd768d81495cb Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 12 Apr 2022 15:03:44 -0400 Subject: [PATCH] Facepalm: join nursery first to avoid channel-closed-too-early --- tests/test_infected_asyncio.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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)