From 46cc0540efaf32dbbc9f366f805aec90ffa3b348 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 15 Oct 2020 22:49:12 -0400 Subject: [PATCH] Add explanation to module load error --- tractor/_actor.py | 16 ++++++++++++++-- tractor/_discovery.py | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tractor/_actor.py b/tractor/_actor.py index 3c0c436..ecae1d7 100644 --- a/tractor/_actor.py +++ b/tractor/_actor.py @@ -304,7 +304,18 @@ class Actor: try: return getattr(self._mods[ns], funcname) except KeyError as err: - raise ModuleNotExposed(*err.args) + mne = ModuleNotExposed(*err.args) + + if ns == '__main__': + msg = ( + "\n\nMake sure you exposed the current module using:\n\n" + "ActorNursery.start_actor(, rpc_module_paths=" + "[__name__])" + ) + + mne.msg += msg + + raise mne async def _stream_handler( self, @@ -594,7 +605,7 @@ class Actor: # Receive runtime state from our parent parent_data = await chan.recv() log.debug( - "Recieved state from parent:\n" + "Received state from parent:\n" f"{parent_data}" ) accept_addr = ( @@ -602,6 +613,7 @@ class Actor: parent_data.pop('bind_port'), ) rvs = parent_data.pop('_runtime_vars') + log.debug(f"Runtime vars are: {rvs}") rvs['_is_root'] = False _state._runtime_vars.update(rvs) diff --git a/tractor/_discovery.py b/tractor/_discovery.py index 13da85d..360b16d 100644 --- a/tractor/_discovery.py +++ b/tractor/_discovery.py @@ -42,6 +42,7 @@ async def get_root( **kwargs, ) -> typing.AsyncGenerator[Union[Portal, LocalPortal], None]: host, port = _runtime_vars['_root_mailbox'] + assert host is not None async with _connect_chan(host, port) as chan: async with open_portal(chan, **kwargs) as portal: yield portal