Make sure that if we fail to kill a child processes we continue to try the rest

This commit is contained in:
clearml 2025-02-24 13:26:49 +02:00
parent c9f5b3d19a
commit 0a13fd79fc

View File

@ -91,11 +91,18 @@ def kill_all_child_processes(pid=None, include_parent=True):
parent = psutil.Process(pid) parent = psutil.Process(pid)
except psutil.Error: except psutil.Error:
# could not find parent process id # could not find parent process id
print("ERROR: could not find parent process id {}".format(pid))
return return
for child in parent.children(recursive=True): for child in parent.children(recursive=True):
try:
child.kill() child.kill()
except:
print("ERROR: could not kill child process id {}".format(child))
if include_parent: if include_parent:
try:
parent.kill() parent.kill()
except:
print("ERROR: could not kill parent process id {}".format(parent))
def terminate_all_child_processes(pid=None, timeout=10., include_parent=True): def terminate_all_child_processes(pid=None, timeout=10., include_parent=True):