From 7f613ac02012b70e75921711a8068d02ca9ff251 Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Wed, 24 Oct 2018 10:17:59 -0700 Subject: [PATCH] Do not fail if process already ended We can expect the subprocess has already ended by the time we're checking for child processes. Handle this case gracefully so that tests do not fail with an exception. --- tests/support/helpers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/support/helpers.py b/tests/support/helpers.py index f669aa4712..242e43739f 100644 --- a/tests/support/helpers.py +++ b/tests/support/helpers.py @@ -1548,7 +1548,11 @@ def win32_kill_process_tree(pid, sig=signal.SIGTERM, include_parent=True, ''' if pid == os.getpid(): raise RuntimeError("I refuse to kill myself") - parent = psutil.Process(pid) + try: + parent = psutil.Process(pid) + except psutil.NoSuchProcess: + log.debug("PID not found alive: %d", pid) + return ([], []) children = parent.children(recursive=True) if include_parent: children.append(parent)