forked from goodboy/tractor
1
0
Fork 0

Set cancelled state in cancel method

asyncgen_closing_fix
Tyler Goodlet 2018-07-11 19:24:08 -04:00
parent 1ade5c5fbb
commit d9aa6119e1
2 changed files with 2 additions and 2 deletions

View File

@ -247,7 +247,6 @@ async def test_trynamic_trio():
'gretchen', 'gretchen',
main=partial(say_hello, 'donny'), main=partial(say_hello, 'donny'),
rpc_module_paths=[__name__], rpc_module_paths=[__name__],
# outlive_main=True
) )
print(await gretchen.result()) print(await gretchen.result())
print(await donny.result()) print(await donny.result())
@ -361,6 +360,7 @@ async def aggregate(seed):
async for value in await portal.run( async for value in await portal.run(
__name__, 'stream_data', seed=seed __name__, 'stream_data', seed=seed
): ):
# leverage trio's built-in backpressure
await q.put(value) await q.put(value)
await q.put(None) await q.put(None)

View File

@ -867,6 +867,7 @@ class ActorNursery:
log.debug(f"Waiting on all subactors to complete") log.debug(f"Waiting on all subactors to complete")
await self.wait() await self.wait()
self.cancelled = True
log.debug(f"All subactors for {self} have terminated") log.debug(f"All subactors for {self} have terminated")
async def __aexit__(self, etype, value, tb): async def __aexit__(self, etype, value, tb):
@ -891,7 +892,6 @@ class ActorNursery:
except Exception as err: except Exception as err:
log.warn(f"Nursery caught {err}, cancelling") log.warn(f"Nursery caught {err}, cancelling")
await self.cancel() await self.cancel()
self.cancelled = True
raise raise
log.debug(f"Nursery teardown complete") log.debug(f"Nursery teardown complete")