From 2a69d179e60b4473a0b7723bda1206ac104f8c90 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 15 Jul 2025 17:32:42 -0400 Subject: [PATCH] Add `Channel.closed/.cancel_called` I.e. the public properties for the private instance var equivs; improves expected introspection usage. --- tractor/ipc/_chan.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/tractor/ipc/_chan.py b/tractor/ipc/_chan.py index 64643d95..9ddab8b0 100644 --- a/tractor/ipc/_chan.py +++ b/tractor/ipc/_chan.py @@ -101,11 +101,27 @@ class Channel: # ^XXX! ONLY set if a remote actor sends an `Error`-msg self._closed: bool = False - # flag set by ``Portal.cancel_actor()`` indicating remote - # (possibly peer) cancellation of the far end actor - # runtime. + # flag set by `Portal.cancel_actor()` indicating remote + # (possibly peer) cancellation of the far end actor runtime. self._cancel_called: bool = False + @property + def closed(self) -> bool: + ''' + Was `.aclose()` successfully called? + + ''' + return self._closed + + @property + def cancel_called(self) -> bool: + ''' + Set when `Portal.cancel_actor()` is called on a portal which + wraps this IPC channel. + + ''' + return self._cancel_called + @property def uid(self) -> tuple[str, str]: '''