fix: apply Windows subprocess fixes to testing agent and initializer

Follow-up to PR #89 - apply the same popen_kwargs pattern with
stdin=DEVNULL and CREATE_NO_WINDOW to _spawn_testing_agent() and
_run_initializer() for consistent Windows behavior.

Also fixes typo: _kill_process_tree -> kill_process_tree

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Auto
2026-01-29 10:56:02 +02:00
parent a4a33e612e
commit 8ae6189c0f

View File

@@ -593,14 +593,20 @@ class ParallelOrchestrator:
cmd.extend(["--model", self.model]) cmd.extend(["--model", self.model])
try: try:
proc = subprocess.Popen( # CREATE_NO_WINDOW on Windows prevents console window pop-ups
cmd, # stdin=DEVNULL prevents blocking on stdin reads
stdout=subprocess.PIPE, popen_kwargs = {
stderr=subprocess.STDOUT, "stdin": subprocess.DEVNULL,
text=True, "stdout": subprocess.PIPE,
cwd=str(AUTOCODER_ROOT), "stderr": subprocess.STDOUT,
env={**os.environ, "PYTHONUNBUFFERED": "1"}, "text": True,
) "cwd": str(AUTOCODER_ROOT),
"env": {**os.environ, "PYTHONUNBUFFERED": "1"},
}
if sys.platform == "win32":
popen_kwargs["creationflags"] = subprocess.CREATE_NO_WINDOW
proc = subprocess.Popen(cmd, **popen_kwargs)
except Exception as e: except Exception as e:
debug_log.log("TESTING", f"FAILED to spawn testing agent: {e}") debug_log.log("TESTING", f"FAILED to spawn testing agent: {e}")
return False, f"Failed to start testing agent: {e}" return False, f"Failed to start testing agent: {e}"
@@ -644,14 +650,20 @@ class ParallelOrchestrator:
print("Running initializer agent...", flush=True) print("Running initializer agent...", flush=True)
proc = subprocess.Popen( # CREATE_NO_WINDOW on Windows prevents console window pop-ups
cmd, # stdin=DEVNULL prevents blocking on stdin reads
stdout=subprocess.PIPE, popen_kwargs = {
stderr=subprocess.STDOUT, "stdin": subprocess.DEVNULL,
text=True, "stdout": subprocess.PIPE,
cwd=str(AUTOCODER_ROOT), "stderr": subprocess.STDOUT,
env={**os.environ, "PYTHONUNBUFFERED": "1"}, "text": True,
) "cwd": str(AUTOCODER_ROOT),
"env": {**os.environ, "PYTHONUNBUFFERED": "1"},
}
if sys.platform == "win32":
popen_kwargs["creationflags"] = subprocess.CREATE_NO_WINDOW
proc = subprocess.Popen(cmd, **popen_kwargs)
debug_log.log("INIT", "Initializer subprocess started", pid=proc.pid) debug_log.log("INIT", "Initializer subprocess started", pid=proc.pid)
@@ -712,7 +724,7 @@ class ParallelOrchestrator:
# CRITICAL: Kill the process tree to clean up any child processes (e.g., Claude CLI) # CRITICAL: Kill the process tree to clean up any child processes (e.g., Claude CLI)
# This prevents zombie processes from accumulating # This prevents zombie processes from accumulating
try: try:
_kill_process_tree(proc, timeout=2.0) kill_process_tree(proc, timeout=2.0)
except Exception as e: except Exception as e:
debug_log.log("CLEANUP", f"Error killing process tree for {agent_type} agent", error=str(e)) debug_log.log("CLEANUP", f"Error killing process tree for {agent_type} agent", error=str(e))
self._on_agent_complete(feature_id, proc.returncode, agent_type, proc) self._on_agent_complete(feature_id, proc.returncode, agent_type, proc)