From 967d0e48360620e2a160ce2eb3c60255164e92e9 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 29 Jul 2025 14:58:18 -0400 Subject: [PATCH] Handle "out-of-layer" remote `Context` cancellation Such that if the local task hasn't resolved but is `trio.Cancelled` and a `.canceller` was set, we report a `'actor-cancelled'` from `.repr_state: str`. Bit of formatting to avoid needless newlines too! --- tractor/_context.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tractor/_context.py b/tractor/_context.py index 0e3ff0c3..9e277a88 100644 --- a/tractor/_context.py +++ b/tractor/_context.py @@ -1011,7 +1011,6 @@ class Context: else: log.cancel( f'Timed out on cancel request of remote task?\n' - f'\n' f'{reminfo}' ) @@ -1492,6 +1491,12 @@ class Context: ): status = 'peer-cancelled' + case ( + Unresolved, + trio.Cancelled(), # any error-type + ) if self.canceller: + status = 'actor-cancelled' + # (remote) error condition case ( Unresolved, @@ -2273,7 +2278,7 @@ async def open_context_from_portal( logmeth = log.exception logmeth( - f'ctx {ctx.side!r}-side exited with {ctx.repr_outcome()}\n' + f'ctx {ctx.side!r}-side exited with {ctx.repr_outcome()!r}\n' ) if debug_mode():