Guard `_mp_fixup_main` on non-empty parent data

Use walrus `:=` to combine the assignment and
truthiness check for `_parent_main_data` into the
`if` condition, cleanly skipping the fixup block
when `inherit_parent_main=False` yields `{}`.

Review: PR #438 (Copilot)
https://github.com/goodboy/tractor/pull/438

(this patch was generated in some part by [`claude-code`][claude-code-gh])
[claude-code-gh]: https://github.com/anthropics/claude-code
subint_spawner_backend
Gud Boi 2026-04-10 12:05:56 -04:00 committed by mahmoudhas
parent e8f1eca8d2
commit 27bf566d75
1 changed files with 6 additions and 2 deletions

View File

@ -552,11 +552,15 @@ class Actor:
''' '''
try: try:
if self._spawn_method == 'trio': if (
parent_data = self._parent_main_data self._spawn_method == 'trio'
and
(parent_data := self._parent_main_data)
):
if 'init_main_from_name' in parent_data: if 'init_main_from_name' in parent_data:
_mp_fixup_main._fixup_main_from_name( _mp_fixup_main._fixup_main_from_name(
parent_data['init_main_from_name']) parent_data['init_main_from_name'])
elif 'init_main_from_path' in parent_data: elif 'init_main_from_path' in parent_data:
_mp_fixup_main._fixup_main_from_path( _mp_fixup_main._fixup_main_from_path(
parent_data['init_main_from_path']) parent_data['init_main_from_path'])