From a8d71f15b7ef9241555f124c65c62252bafd1fb3 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 3 Jan 2022 12:45:08 -0500 Subject: [PATCH] Always raise a received result-as-error in spawn tasks --- tractor/_spawn.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tractor/_spawn.py b/tractor/_spawn.py index ead91df..08d3afa 100644 --- a/tractor/_spawn.py +++ b/tractor/_spawn.py @@ -139,11 +139,13 @@ 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 @@ -167,11 +169,13 @@ async def cancel_on_completion( # in ``errors`` which will be reraised inside # a MultiError and we still send out a cancel request result = await exhaust_portal(portal, actor) + if isinstance(result, Exception): errors[actor.uid] = result log.warning( f"Cancelling {portal.channel.uid} after error {result}" ) + raise result else: log.runtime(