Wrap remote import-time errors just the same

contexts
Tyler Goodlet 2019-01-12 17:56:22 -05:00
parent fffddf88dd
commit 06c908f285
1 changed files with 2 additions and 12 deletions

View File

@ -18,7 +18,6 @@ from .log import get_console_log, get_logger
from ._exceptions import ( from ._exceptions import (
pack_error, pack_error,
unpack_error, unpack_error,
InternalActorError,
ModuleNotExposed ModuleNotExposed
) )
from ._portal import ( from ._portal import (
@ -228,17 +227,9 @@ class Actor:
code (if it exists). code (if it exists).
""" """
for path in self.rpc_module_paths: for path in self.rpc_module_paths:
log.debug(f"Attempting to import {path}")
self._mods[path] = importlib.import_module(path) self._mods[path] = importlib.import_module(path)
# XXX: triggers an internal error which can cause a hanging
# problem (without the recently added .throw()) on teardown
# (root nursery tears down thus killing all channels before
# sending cancels to subactors during actor nursery teardown
# - has to do with await main() in MainProcess)
# if self.name == 'gretchen':
# self._mods.pop('test_discovery')
# TODO: how to test the above?
def _get_rpc_func(self, ns, funcname): def _get_rpc_func(self, ns, funcname):
try: try:
return getattr(self._mods[ns], funcname) return getattr(self._mods[ns], funcname)
@ -394,8 +385,7 @@ class Actor:
# Push this error to all local channel consumers # Push this error to all local channel consumers
# (normally portals) by marking the channel as errored # (normally portals) by marking the channel as errored
assert chan.uid assert chan.uid
exc = unpack_error( exc = unpack_error(msg, chan=chan)
msg, chan=chan, err_type=InternalActorError)
chan._exc = exc chan._exc = exc
raise exc raise exc