diff --git a/tests/test_tractor.py b/tests/test_tractor.py index 6cb6a10..246cdf2 100644 --- a/tests/test_tractor.py +++ b/tests/test_tractor.py @@ -247,7 +247,6 @@ async def test_trynamic_trio(): 'gretchen', main=partial(say_hello, 'donny'), rpc_module_paths=[__name__], - # outlive_main=True ) print(await gretchen.result()) print(await donny.result()) @@ -361,6 +360,7 @@ async def aggregate(seed): async for value in await portal.run( __name__, 'stream_data', seed=seed ): + # leverage trio's built-in backpressure await q.put(value) await q.put(None) diff --git a/tractor/__init__.py b/tractor/__init__.py index 9658b80..938a404 100644 --- a/tractor/__init__.py +++ b/tractor/__init__.py @@ -867,6 +867,7 @@ class ActorNursery: log.debug(f"Waiting on all subactors to complete") await self.wait() + self.cancelled = True log.debug(f"All subactors for {self} have terminated") async def __aexit__(self, etype, value, tb): @@ -891,7 +892,6 @@ class ActorNursery: except Exception as err: log.warn(f"Nursery caught {err}, cancelling") await self.cancel() - self.cancelled = True raise log.debug(f"Nursery teardown complete")