diff --git a/amlb/utils/process.py b/amlb/utils/process.py index c32fad3b1..593ed1ff8 100644 --- a/amlb/utils/process.py +++ b/amlb/utils/process.py @@ -286,11 +286,17 @@ def on_proc_terminated(proc): children.append(parent) for proc in children: log.warning("Terminating process %s.", proc) - proc.terminate() + try: + proc.terminate() + except psutil.NoSuchProcess: + pass terminated, alive = psutil.wait_procs(children, timeout=timeout, callback=on_proc_terminated) for proc in alive: log.warning("Killing process %s.", proc) - proc.kill() + try: + proc.kill() + except psutil.NoSuchProcess: + pass def call_in_subprocess(target, *args, **kwargs):