From 79c38b04e712259dee1137f0fd2aa93384b3dc80 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 12 Oct 2020 23:28:36 -0400 Subject: [PATCH] Report `trio.Cancelled` when exhausting portals.. For reliable remote cancellation we need to "report" `trio.Cancelled`s (just like any other error) when exhausting a portal such that the caller can make decisions about cancelling the respective actor if need be. Resolves #156 --- tractor/_spawn.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tractor/_spawn.py b/tractor/_spawn.py index 2a2f602..2065967 100644 --- a/tractor/_spawn.py +++ b/tractor/_spawn.py @@ -112,6 +112,11 @@ async def exhaust_portal( except (Exception, trio.MultiError) as err: # we reraise in the parent task via a ``trio.MultiError`` return err + except trio.Cancelled as err: + # lol, of course we need this too ;P + # TODO: merge with above? + log.warning(f"Cancelled result waiter for {portal.actor.uid}") + return err else: log.debug(f"Returning final result: {final}") return final