Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions scripts/dag_traversal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)."""

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
Loading