forked from goodboy/tractor
1
0
Fork 0

Get rid of external teardown trigger

patch-async-enter-all
overclockworked64 2021-10-22 03:10:46 +02:00
parent 3020793415
commit 8d9ad6bac9
No known key found for this signature in database
GPG Key ID: 0E4A3AD9DB596812
1 changed files with 0 additions and 4 deletions

View File

@ -23,19 +23,15 @@ async def worker(ctx: tractor.Context) -> None:
@tractor_test @tractor_test
async def test_streaming_to_actor_cluster() -> None: async def test_streaming_to_actor_cluster() -> None:
teardown_trigger = trio.Event()
async with ( async with (
open_actor_cluster(modules=[__name__]) as portals, open_actor_cluster(modules=[__name__]) as portals,
async_enter_all( async_enter_all(
mngrs=[p.open_context(worker) for p in portals.values()], mngrs=[p.open_context(worker) for p in portals.values()],
teardown_trigger=teardown_trigger,
) as contexts, ) as contexts,
async_enter_all( async_enter_all(
mngrs=[ctx[0].open_stream() for ctx in contexts], mngrs=[ctx[0].open_stream() for ctx in contexts],
teardown_trigger=teardown_trigger,
) as streams, ) as streams,
): ):
with trio.move_on_after(1): with trio.move_on_after(1):
for stream in itertools.cycle(streams): for stream in itertools.cycle(streams):
await stream.send(MESSAGE) await stream.send(MESSAGE)
teardown_trigger.set()