From 87e3d32992680e57fe862d5fa115248e0751d08a Mon Sep 17 00:00:00 2001 From: overclockworked64 Date: Fri, 22 Oct 2021 03:03:41 +0200 Subject: [PATCH] Get rid of external teardown trigger because #245 resolves the problem --- tractor/trionics/_mngrs.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/tractor/trionics/_mngrs.py b/tractor/trionics/_mngrs.py index bfc715b..ca75c55 100644 --- a/tractor/trionics/_mngrs.py +++ b/tractor/trionics/_mngrs.py @@ -17,7 +17,6 @@ async def _enter_and_wait( mngr: AsyncContextManager[T], unwrapped: dict[int, T], all_entered: trio.Event, - teardown_trigger: trio.Event, ) -> None: '''Open the async context manager deliver it's value to this task's spawner and sleep until cancelled. @@ -29,18 +28,13 @@ async def _enter_and_wait( if all(unwrapped.values()): all_entered.set() - await teardown_trigger.wait() + await trio.sleep_forever() @acm async def async_enter_all( mngrs: Sequence[AsyncContextManager[T]], - teardown_trigger: trio.Event, ) -> AsyncGenerator[tuple[T, ...], None]: - """This async context manager expects a 'teardown_trigger' from the - outside world which will be used internally to gracefully teardown - individual context managers. - """ unwrapped = {}.fromkeys(id(mngr) for mngr in mngrs) all_entered = trio.Event() @@ -52,10 +46,11 @@ async def async_enter_all( mngr, unwrapped, all_entered, - teardown_trigger, ) # deliver control once all managers have started up await all_entered.wait() yield tuple(unwrapped.values()) + + n.cancel_scope.cancel() \ No newline at end of file