From 5822d38ae40a79afd2e97caf8af7447ab93531f8 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 15 Oct 2020 22:47:11 -0400 Subject: [PATCH] Set _is_root runtime var in _main() --- tractor/__init__.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tractor/__init__.py b/tractor/__init__.py index 5ed843f..adaad38 100644 --- a/tractor/__init__.py +++ b/tractor/__init__.py @@ -20,8 +20,8 @@ from ._state import current_actor from . import _state from ._exceptions import RemoteActorError, ModuleNotExposed from ._debug import breakpoint, post_mortem -from . import msg from . import _spawn +from . import msg __all__ = [ @@ -60,16 +60,23 @@ async def _main( """ logger = log.get_logger('tractor') + # mark top most level process as root actor + _state._runtime_vars['_is_root'] = True + if start_method is not None: _spawn.try_set_start_method(start_method) if debug_mode and _spawn._spawn_method == 'trio': _state._runtime_vars['_debug_mode'] = True + # expose internal debug module to every actor allowing # for use of ``await tractor.breakpoint()`` kwargs.setdefault('rpc_module_paths', []).append('tractor._debug') + elif debug_mode: - raise RuntimeError("Debug mode is only supported for the `trio` backend!") + raise RuntimeError( + "Debug mode is only supported for the `trio` backend!" + ) main = partial(async_fn, *args) @@ -134,9 +141,6 @@ def run( This is tractor's main entry and the start point for any async actor. """ - # mark top most level process as root actor - _state._runtime_vars['_is_root'] = True - return trio.run( partial( # our entry