From bd38204fde928bd26307d29c81a5cf7e2bd9d0d1 Mon Sep 17 00:00:00 2001 From: goodboy Date: Thu, 13 Aug 2026 18:41:20 -0400 Subject: [PATCH] Preserve docs-example body failures Best-effort subprocess teardown must not replace the exception raised by the test body. Suppress cleanup errors only while propagating that active failure; keep raising teardown errors on normal body exit. Also close the Windows stdin pipe after its bounded leader reap. Review: PR #480 (goodboy) https://github.com/goodboy/tractor/pull/480 (this patch was generated in some part by `opencode` using `gpt-5.6-sol` (`openai`)) --- tests/test_docs_examples.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/test_docs_examples.py b/tests/test_docs_examples.py index f23fc926..7d9b6418 100644 --- a/tests/test_docs_examples.py +++ b/tests/test_docs_examples.py @@ -48,6 +48,8 @@ def _reap_killed_proc( return proc.communicate() proc.wait(timeout=5) + if proc.stdin: + proc.stdin.close() if proc.stdout: proc.stdout.close() if proc.stderr: @@ -257,7 +259,15 @@ def run_example_in_subproc( assert not proc.returncode try: yield proc - finally: + except BaseException: + if proc.poll() is None: + try: + _kill_proc_tree(proc) + _reap_killed_proc(proc) + except Exception: + pass + raise + else: if proc.poll() is None: _kill_proc_tree(proc) _reap_killed_proc(proc)