From 8496828a90fd93a1e708332e22a7a1ff3bdac293 Mon Sep 17 00:00:00 2001 From: Andy Lee Date: Tue, 12 Aug 2025 22:44:19 -0700 Subject: [PATCH] fix: prevent wrapper script from killing itself in cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove overly aggressive pattern 'python.*pytest' that matched wrapper itself - Add current PID check to avoid killing wrapper process - Add exclusion for wrapper and debug script names - This fixes exit code 137 (SIGKILL) issue where wrapper killed itself Root cause: cleanup function was killing the wrapper process itself, causing immediate termination with no output in CI. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- scripts/ci_pytest_wrapper.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/scripts/ci_pytest_wrapper.py b/scripts/ci_pytest_wrapper.py index 0d228b1..10645bb 100755 --- a/scripts/ci_pytest_wrapper.py +++ b/scripts/ci_pytest_wrapper.py @@ -16,12 +16,11 @@ def cleanup_all_processes(): print("🧹 [CLEANUP] Performing aggressive cleanup...") # Kill by pattern - use separate calls to avoid shell injection + # Avoid killing ourselves by being more specific patterns = [ "embedding_server", "hnsw_embedding", "zmq", - "python.*pytest", - "scripts/ci_debug_pytest", ] for pattern in patterns: @@ -30,12 +29,23 @@ def cleanup_all_processes(): except Exception: pass - # Clean up any hanging Python processes with specific patterns + # Clean up specific pytest processes but NOT the wrapper itself try: result = subprocess.run(["ps", "aux"], capture_output=True, text=True, timeout=5) lines = result.stdout.split("\n") + current_pid = str(os.getpid()) + for line in lines: - if "python" in line and ("test_" in line or "pytest" in line or "embedding" in line): + # Skip our own process + if current_pid in line: + continue + # Only kill actual pytest processes, not wrapper processes + if ( + "python" in line + and "pytest" in line + and "ci_pytest_wrapper.py" not in line + and "ci_debug_pytest.py" not in line + ): try: pid = line.split()[1] subprocess.run(["kill", "-9", pid], timeout=2)