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)