Skip to content

Commit

Permalink
util/sim: Handle ProcessLookupError in subprocess termination (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
colluca authored May 15, 2024
1 parent cd53d8b commit 1f98478
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions util/sim/sim_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,12 @@ def get_living_subprocesses():
iterations = 0
while get_living_subprocesses() and iterations < 10:
living_subprocs = get_living_subprocesses()
print(f'{len(living_subprocs)} living subprocesses of {ppid}')
print(living_subprocs)
[os.kill(proc.info['pid'], signal.SIGKILL) for proc in living_subprocs]
print(f'{len(living_subprocs)} living subprocesses of {ppid}\n{living_subprocs}')
for proc in living_subprocs:
try:
os.kill(proc.info['pid'], signal.SIGKILL)
except ProcessLookupError:
pass
iterations += 1
time.sleep(1)
if iterations == 10:
Expand Down

0 comments on commit 1f98478

Please sign in to comment.