Resolve relay `emit` only when relaying

`supervise_run_process()` bound the relay `emit` method
(`getattr(log, relay_level)`) unconditionally at entry, so a
bad/typo'd `relay_level` raised `AttributeError` even for a
call that requested NO relay (the common silent path). Bind
it lazily behind `relay_stdout or relay_stderr` so only an
actual relay request validates the level.

Review: PR #465 (copilot-pull-request-reviewer)
https://github.com/goodboy/tractor/pull/465#pullrequestreview-4548191641

(this patch was generated in some part by [`claude-code`][claude-code-gh])
[claude-code-gh]: https://github.com/anthropics/claude-code
wkt/start_or_cancel_tests_474
Gud Boi 2026-06-24 19:05:55 -04:00
parent e076296cda
commit a3f8765264
1 changed files with 8 additions and 1 deletions

View File

@ -190,7 +190,14 @@ async def supervise_run_process(
) )
''' '''
emit: Callable[[str], None] = getattr(log, relay_level) # resolve the relay emit-method ONLY when actually relaying so
# a bad/typo'd `relay_level` can't crash a NON-relay call (and
# we don't bind an unused method on the common silent path).
emit: Callable[[str], None]|None = (
getattr(log, relay_level)
if (relay_stdout or relay_stderr)
else None
)
tag: str = ( tag: str = (
label label
or or