From 5d7a4e2b12997d6e711c06b775bfa78d809745f1 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 25 Dec 2020 15:10:20 -0500 Subject: [PATCH] Denoise some common teardown "errors" to warnings. --- tractor/_actor.py | 2 +- tractor/_debug.py | 6 ++---- tractor/_ipc.py | 2 +- tractor/_trionics.py | 5 ++++- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tractor/_actor.py b/tractor/_actor.py index 87e6139..25a4f77 100644 --- a/tractor/_actor.py +++ b/tractor/_actor.py @@ -144,7 +144,7 @@ async def _invoke( try: await chan.send(err_msg) except trio.ClosedResourceError: - log.exception( + log.warning( f"Failed to ship error to caller @ {chan.uid}") if cs is None: # error is from above code not from rpc invocation diff --git a/tractor/_debug.py b/tractor/_debug.py index f9af7a6..45cae31 100644 --- a/tractor/_debug.py +++ b/tractor/_debug.py @@ -15,6 +15,7 @@ from .log import get_logger from . import _state from ._discovery import get_root from ._state import is_root_process +from ._exceptions import is_multi_cancelled try: # wtf: only exported when installed in dev mode? @@ -318,10 +319,7 @@ async def _maybe_enter_pm(err): # Really we just want to mostly avoid catching KBIs here so there # might be a simpler check we can do? - and trio.MultiError.filter( - lambda exc: exc if not isinstance(exc, trio.Cancelled) else None, - err, - ) + and not is_multi_cancelled(err) ): log.warning("Actor crashed, entering debug mode") await post_mortem() diff --git a/tractor/_ipc.py b/tractor/_ipc.py index 7f6a498..32b8966 100644 --- a/tractor/_ipc.py +++ b/tractor/_ipc.py @@ -51,7 +51,7 @@ class MsgpackStream: data = await self.stream.receive_some(2**10) log.trace(f"received {data}") # type: ignore except trio.BrokenResourceError: - log.error(f"Stream connection {self.raddr} broke") + log.warning(f"Stream connection {self.raddr} broke") return if data == b'': diff --git a/tractor/_trionics.py b/tractor/_trionics.py index 4d9e15f..0d54b24 100644 --- a/tractor/_trionics.py +++ b/tractor/_trionics.py @@ -13,6 +13,7 @@ from ._state import current_actor from .log import get_logger, get_loglevel from ._actor import Actor from ._portal import Portal +from ._exceptions import is_multi_cancelled from . import _state from . import _spawn @@ -246,7 +247,9 @@ async def open_nursery() -> typing.AsyncGenerator[ActorNursery, None]: # For now, shield both. with trio.CancelScope(shield=True): etype = type(err) - if etype in (trio.Cancelled, KeyboardInterrupt): + if etype in (trio.Cancelled, KeyboardInterrupt) or ( + is_multi_cancelled(err) + ): log.warning( f"Nursery for {current_actor().uid} was " f"cancelled with {etype}")