From 6006adc0de5c26fb4ff16a6d26c263ccf85a8e9e Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sat, 31 Jul 2021 13:56:26 -0400 Subject: [PATCH] Hide `_invoke()` tb, move actor error to exceptions mod --- tractor/_actor.py | 10 ++++------ tractor/_exceptions.py | 7 ++++++- tractor/_spawn.py | 3 ++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/tractor/_actor.py b/tractor/_actor.py index c45449d..0dbaede 100644 --- a/tractor/_actor.py +++ b/tractor/_actor.py @@ -41,10 +41,6 @@ from . import _mp_fixup_main log = get_logger('tractor') -class ActorFailure(Exception): - "General actor failure" - - async def _invoke( actor: 'Actor', @@ -56,8 +52,10 @@ async def _invoke( Union[trio.CancelScope, BaseException] ] = trio.TASK_STATUS_IGNORED, ): - """Invoke local func and deliver result(s) over provided channel. - """ + '''Invoke local func and deliver result(s) over provided channel. + + ''' + __tracebackhide__ = True treat_as_gen = False # possible a traceback (not sure what typing is for this..) diff --git a/tractor/_exceptions.py b/tractor/_exceptions.py index 30c872b..9c3edac 100644 --- a/tractor/_exceptions.py +++ b/tractor/_exceptions.py @@ -12,6 +12,10 @@ import trio _this_mod = importlib.import_module(__name__) +class ActorFailure(Exception): + "General actor failure" + + class RemoteActorError(Exception): # TODO: local recontruction of remote exception deats "Remote actor exception bundled locally" @@ -40,6 +44,7 @@ class InternalActorError(RemoteActorError): class TransportClosed(trio.ClosedResourceError): "Underlying channel transport was closed prior to use" + class ContextCancelled(RemoteActorError): "Inter-actor task context cancelled itself on the callee side." @@ -58,7 +63,7 @@ class NoRuntime(RuntimeError): def pack_error( exc: BaseException, - tb = None, + tb=None, ) -> Dict[str, Any]: """Create an "error message" for tranmission over diff --git a/tractor/_spawn.py b/tractor/_spawn.py index e54a652..ae1c708 100644 --- a/tractor/_spawn.py +++ b/tractor/_spawn.py @@ -29,8 +29,9 @@ from ._state import ( from .log import get_logger from ._portal import Portal -from ._actor import Actor, ActorFailure +from ._actor import Actor from ._entry import _mp_main +from ._exceptions import ActorFailure log = get_logger('tractor')