fix: prevent wrapper script from killing itself in cleanup

- 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 <noreply@anthropic.com>
This commit is contained in:
Andy Lee
2025-08-12 22:44:19 -07:00
parent 7244518901
commit 8496828a90

View File

@@ -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)