Skip to content

Commit

Permalink
Debug background process stopping
Browse files Browse the repository at this point in the history
  • Loading branch information
dostuffthatmatters committed Nov 13, 2023
1 parent 9388a56 commit 90b0553
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions tum_esm_utils/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,18 @@ def terminate_process(script_path: str) -> list[int]:
"""Terminate all processes that have the given script as their
entrypoint. Returns the list of terminated PIDs."""

termination_pids = get_process_pids(script_path)
for pid in termination_pids:
os.system(f"kill {pid}")
termination_pids: list[int] = []
for p in psutil.process_iter():
try:
if p.cmdline()[1] == script_path:
termination_pids.append(p.pid)
p.kill()
except (
psutil.AccessDenied,
psutil.ZombieProcess,
psutil.NoSuchProcess,
IndexError,
):
pass

return termination_pids

0 comments on commit 90b0553

Please sign in to comment.