diff --git a/tests/test_spawning.py b/tests/test_spawning.py index d61282f5..4bc0504e 100644 --- a/tests/test_spawning.py +++ b/tests/test_spawning.py @@ -204,23 +204,23 @@ def test_loglevel_propagated_to_subactor( assert 'yoyoyo' in captured.err -def test_start_actor_can_skip_parent_main_replay( +def test_start_actor_can_skip_parent_main_inheritance( start_method, reg_addr, monkeypatch, ): if start_method != 'trio': pytest.skip( - 'parent main replay opt-out only affects the trio spawn backend' + 'parent main inheritance opt-out only affects the trio spawn backend' ) from tractor.spawn import _mp_fixup_main monkeypatch.setattr( _mp_fixup_main, '_mp_figure_out_main', - lambda replay_parent_main=True: ( + lambda inherit_parent_main=True: ( {'init_main_from_name': __name__} - if replay_parent_main + if inherit_parent_main else {} ), ) @@ -238,7 +238,7 @@ def test_start_actor_can_skip_parent_main_replay( isolated = await an.run_in_actor( get_main_mod_name, name='isolated-parent-main', - replay_parent_main=False, + inherit_parent_main=False, ) assert await replaying.result() == '__mp_main__' diff --git a/tractor/runtime/_runtime.py b/tractor/runtime/_runtime.py index a9ae0f54..17119ffd 100644 --- a/tractor/runtime/_runtime.py +++ b/tractor/runtime/_runtime.py @@ -244,7 +244,7 @@ class Actor: loglevel: str|None = None, registry_addrs: list[Address]|None = None, spawn_method: str|None = None, - replay_parent_main: bool = True, + inherit_parent_main: bool = True, arbiter_addr: UnwrappedAddress|None = None, @@ -269,7 +269,7 @@ class Actor: # retrieve and store parent `__main__` data which # will be passed to children self._parent_main_data = _mp_fixup_main._mp_figure_out_main( - replay_parent_main, + inherit_parent_main, ) # TODO? only add this when `is_debug_mode() == True` no? @@ -1024,6 +1024,11 @@ class Actor: ) self._parent_main_data = spawnspec._parent_main_data + # XXX QUESTION(s)^^^ + # -[ ] already set in `.__init__()` right, but how is + # it diff from this blatant parent copy? + # -[ ] do we need/want the .__init__() value in + # just the root case orr? return ( chan, diff --git a/tractor/runtime/_supervise.py b/tractor/runtime/_supervise.py index 9645c982..3e7fa63c 100644 --- a/tractor/runtime/_supervise.py +++ b/tractor/runtime/_supervise.py @@ -194,7 +194,7 @@ class ActorNursery: loglevel: str|None = None, # set log level per subactor debug_mode: bool|None = None, infect_asyncio: bool = False, - replay_parent_main: bool = True, + inherit_parent_main: bool = True, # TODO: ideally we can rm this once we no longer have # a `._ria_nursery` since the dependent APIs have been @@ -207,7 +207,7 @@ class ActorNursery: Start a (daemon) actor: an process that has no designated "main task" besides the runtime. - Pass ``replay_parent_main=False`` to keep this child on its own + Pass ``inherit_parent_main=False`` to keep this child on its own bootstrap module instead of re-running the parent's ``__main__`` during startup. @@ -247,7 +247,7 @@ class ActorNursery: # modules allowed to invoked funcs from enable_modules=enable_modules, loglevel=loglevel, - replay_parent_main=replay_parent_main, + inherit_parent_main=inherit_parent_main, # verbatim relay this actor's registrar addresses registry_addrs=current_actor().registry_addrs, @@ -295,7 +295,7 @@ class ActorNursery: enable_modules: list[str] | None = None, loglevel: str | None = None, # set log level per subactor infect_asyncio: bool = False, - replay_parent_main: bool = True, + inherit_parent_main: bool = True, proc_kwargs: dict[str, any] = {}, **kwargs, # explicit args to ``fn`` @@ -327,7 +327,7 @@ class ActorNursery: # use the run_in_actor nursery nursery=self._ria_nursery, infect_asyncio=infect_asyncio, - replay_parent_main=replay_parent_main, + inherit_parent_main=inherit_parent_main, proc_kwargs=proc_kwargs ) diff --git a/tractor/spawn/_mp_fixup_main.py b/tractor/spawn/_mp_fixup_main.py index 0189e6de..7cf6bf15 100644 --- a/tractor/spawn/_mp_fixup_main.py +++ b/tractor/spawn/_mp_fixup_main.py @@ -34,13 +34,13 @@ ORIGINAL_DIR = os.path.abspath(os.getcwd()) def _mp_figure_out_main( - replay_parent_main: bool = True, + inherit_parent_main: bool = True, ) -> dict[str, str]: """Taken from ``multiprocessing.spawn.get_preparation_data()``. Retrieve parent actor `__main__` module data. """ - if not replay_parent_main: + if not inherit_parent_main: return {} d = {}