From d9aa6119e1676f47bed911e4c09b26ae1a5619d5 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 11 Jul 2018 19:24:08 -0400 Subject: [PATCH] Set cancelled state in cancel method --- tests/test_tractor.py | 2 +- tractor/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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")