From 9c320c48ed6640766a848c42598652c9992ae903 Mon Sep 17 00:00:00 2001 From: zhikaip Date: Thu, 1 Oct 2026 22:05:08 +0100 Subject: [PATCH] fix(scripts/dag_traversal.py): kill timed-out builds on Windows `os.killpg` does not exist on Windows, so the first per-module timeout in `rm_set_option.py` raised `AttributeError` and left the build running. Add a `_kill_tree` helper that falls back to `taskkill /F /T`. Co-Authored-By: Claude Opus 5.5 --- scripts/dag_traversal.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/dag_traversal.py b/scripts/dag_traversal.py index d0c3cf6e50c5be..353f1698be6a91 100755 --- a/scripts/dag_traversal.py +++ b/scripts/dag_traversal.py @@ -46,6 +46,15 @@ SHOW_CURSOR = "\033[?25h" + +def _kill_tree(proc: subprocess.Popen) -> None: + """Kill a build and all its children (`os.killpg` does not exist on Windows).""" + if hasattr(os, "killpg"): + os.killpg(proc.pid, signal.SIGKILL) + else: + subprocess.run(["taskkill", "/F", "/T", "/PID", str(proc.pid)], + capture_output=True) + class ShutdownError(Exception): """Raised when a shutdown has been requested (e.g. Ctrl-C).""" @@ -98,7 +107,7 @@ def _kill_builds(self): with self._active_builds_lock: for proc in self._active_builds: try: - os.killpg(proc.pid, signal.SIGKILL) + _kill_tree(proc) except (ProcessLookupError, PermissionError): try: proc.kill() @@ -160,7 +169,7 @@ def lake_build( self._active_builds.discard(proc) if proc.poll() is None: try: - os.killpg(proc.pid, signal.SIGKILL) + _kill_tree(proc) except (ProcessLookupError, PermissionError): proc.kill() proc.wait()