From 86d4e0d3edf82ab4693c14fcc921a85daa529f83 Mon Sep 17 00:00:00 2001 From: goodboy Date: Tue, 14 Apr 2026 13:57:01 -0400 Subject: [PATCH] Harden `sig_prog()` retries, adjust debugger test timeouts Retry signal delivery in `sig_prog()` up to `tries` times (default 3) w/ `canc_timeout` sleep between attempts; only fall back to `_KILL_SIGNAL` after all retries exhaust. Bump default timeout 0.1 -> 0.2. Also, - `test_multi_nested_subactors_error_through_nurseries` gives the first prompt iteration a 5s timeout even on linux bc the initial crash sequence can be slow to arrive at a `pdb` prompt (this commit msg was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code --- tests/conftest.py | 37 +++++++++++++++++++++++++++++++------ tests/devx/test_debugger.py | 27 +++++++++++++++++++-------- 2 files changed, 50 insertions(+), 14 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 54efb945..1fad2255 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -199,15 +199,40 @@ def ci_env() -> bool: def sig_prog( proc: subprocess.Popen, sig: int, - canc_timeout: float = 0.1, + canc_timeout: float = 0.2, + tries: int = 3, ) -> int: - "Kill the actor-process with ``sig``." - proc.send_signal(sig) - time.sleep(canc_timeout) - if not proc.poll(): + ''' + Kill the actor-process with `sig`. + + Prefer to kill with the provided signal and + failing a `canc_timeout`, send a `SIKILL`-like + to ensure termination. + + ''' + for i in range(tries): + proc.send_signal(sig) + if not proc.poll(): + print( + f'WARNING, proc still alive after,\n' + f'canc_timeout={canc_timeout!r}\n' + f'sig={sig!r}\n' + f'\n' + f'{proc.args!r}\n' + ) + time.sleep(canc_timeout) + else: # TODO: why sometimes does SIGINT not work on teardown? # seems to happen only when trace logging enabled? - proc.send_signal(_KILL_SIGNAL) + if not proc.poll(): + breakpoint() + print( + f'XXX WARNING KILLING PROG WITH SIGINT XXX\n' + f'canc_timeout={canc_timeout!r}\n' + f'{proc.args!r}\n' + ) + proc.send_signal(_KILL_SIGNAL) + ret: int = proc.wait() assert ret diff --git a/tests/devx/test_debugger.py b/tests/devx/test_debugger.py index e6e40b51..d5fd759b 100644 --- a/tests/devx/test_debugger.py +++ b/tests/devx/test_debugger.py @@ -785,17 +785,28 @@ def test_multi_nested_subactors_error_through_nurseries( # timed_out_early: bool = False - for send_char in itertools.cycle(['c', 'q']): + for ( + i, + send_char, + ) in enumerate(itertools.cycle(['c', 'q'])): + + timeout: float = -1 + if ( + _non_linux + and + ci_env + ): + timeout: float = 6 + + # XXX linux but the first crash sequence + # can take longer to arrive at a prompt. + elif i == 0: + timeout = 5 + try: child.expect( PROMPT, - timeout=( - 6 if ( - _non_linux - and - ci_env - ) else -1 - ), + timeout=timeout, ) child.sendline(send_char) time.sleep(0.01)