From a3f8765264c85e3e4129638faa4299f61e0b32df Mon Sep 17 00:00:00 2001 From: goodboy Date: Wed, 24 Jun 2026 19:05:55 -0400 Subject: [PATCH] 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 --- tractor/trionics/_subproc.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tractor/trionics/_subproc.py b/tractor/trionics/_subproc.py index ec894ba2..ab287d52 100644 --- a/tractor/trionics/_subproc.py +++ b/tractor/trionics/_subproc.py @@ -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 = ( label or