From 32c7a06e6a197cfc5dc6406b9a0dd29e68094b79 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 10 Dec 2018 23:13:25 -0500 Subject: [PATCH] Cancel remote async gens when `aclose()` is called --- tractor/_portal.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tractor/_portal.py b/tractor/_portal.py index 28e28f4..136683f 100644 --- a/tractor/_portal.py +++ b/tractor/_portal.py @@ -139,7 +139,9 @@ class Portal: "Received internal error at portal?") raise unpack_error(msg, self.channel) - except StopAsyncIteration: + except GeneratorExit: + # for now this msg cancels an ongoing remote task + await self.channel.send({'cancel': True, 'cid': cid}) log.debug( f"Cancelling async gen call {cid} to " f"{self.channel.uid}")