Commit 2e8be7fc authored by Sebastien Robin's avatar Sebastien Robin

testnode: avoid testnode crash when trying to kill a process already dead

parent ddab98f9
...@@ -110,10 +110,10 @@ def killCommand(pid): ...@@ -110,10 +110,10 @@ def killCommand(pid):
try: try:
process = psutil.Process(pid) process = psutil.Process(pid)
process.suspend() process.suspend()
process_list = [process]
new_list = process.children(recursive=True)
except psutil.Error as e: except psutil.Error as e:
return return
process_list = [process]
new_list = process.children(recursive=True)
while new_list: while new_list:
process_list += new_list process_list += new_list
for child in new_list: for child in new_list:
...@@ -122,7 +122,10 @@ def killCommand(pid): ...@@ -122,7 +122,10 @@ def killCommand(pid):
except psutil.Error as e: except psutil.Error as e:
logger.debug("killCommand/suspend: %s", e) logger.debug("killCommand/suspend: %s", e)
time.sleep(1) time.sleep(1)
new_list = set(process.children(recursive=True)).difference(process_list) try:
new_list = set(process.children(recursive=True)).difference(process_list)
except psutil.Error as e:
new_list = []
for process in process_list: for process in process_list:
try: try:
process.kill() process.kill()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment