Merge pull request #50212 from dwoz/test_no_fail

Do not fail if process already ended
This commit is contained in:
Nicole Thomas 2018-10-24 15:22:46 -04:00 committed by GitHub
commit 6b4e07be03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)