Facepalm: join nursery first to avoid channel-closed-too-early
parent
90593611bb
commit
333fad8819
|
@ -256,8 +256,13 @@ async def stream_from_aio(
|
||||||
if fan_out:
|
if fan_out:
|
||||||
# start second task that get's the same stream value set.
|
# start second task that get's the same stream value set.
|
||||||
async with (
|
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,
|
chan.subscribe() as br,
|
||||||
|
|
||||||
|
trio.open_nursery() as n,
|
||||||
):
|
):
|
||||||
n.start_soon(consume, br)
|
n.start_soon(consume, br)
|
||||||
await consume(chan)
|
await consume(chan)
|
||||||
|
|
Loading…
Reference in New Issue