From a71a958f549aab1aa4d9a2e6a928f5e28373d7ac Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 17 Mar 2022 08:59:25 -0400 Subject: [PATCH] Log context cancellation using `.cancel()` loglevel --- tractor/_streaming.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/tractor/_streaming.py b/tractor/_streaming.py index bb86dcd..5c20359 100644 --- a/tractor/_streaming.py +++ b/tractor/_streaming.py @@ -444,19 +444,24 @@ class Context: # (currently) that other portal APIs (``Portal.run()``, # ``.run_in_actor()``) do their own error checking at the point # of the call and result processing. - log.error( - f'Remote context error for {self.chan.uid}:{self.cid}:\n' - f'{msg["error"]["tb_str"]}' - ) error = unpack_error(msg, self.chan) if ( - isinstance(error, ContextCancelled) and - self._cancel_called + isinstance(error, ContextCancelled) ): - # this is an expected cancel request response message - # and we don't need to raise it in scope since it will - # potentially override a real error - return + log.cancel( + f'Remote context error for {self.chan.uid}:{self.cid}:\n' + f'{msg["error"]["tb_str"]}' + ) + if self._cancel_called: + # this is an expected cancel request response message + # and we don't need to raise it in scope since it will + # potentially override a real error + return + else: + log.error( + f'Remote context error for {self.chan.uid}:{self.cid}:\n' + f'{msg["error"]["tb_str"]}' + ) self._error = error