mirror of
https://github.com/ansible/awx.git
synced 2026-03-10 22:19:28 -02:30
Handle Ubuntu 12.04 psutil recursive cancel
Ubuntu has a crazy old version of psutil, we'll fall back to sigkill for that platform
This commit is contained in:
@@ -437,16 +437,20 @@ class BaseTask(Task):
|
|||||||
if instance.cancel_flag:
|
if instance.cancel_flag:
|
||||||
try:
|
try:
|
||||||
if settings.AWX_PROOT_ENABLED:
|
if settings.AWX_PROOT_ENABLED:
|
||||||
|
# NOTE: Refactor this once we get a newer psutil across the board
|
||||||
if not psutil:
|
if not psutil:
|
||||||
os.kill(child.pid, signal.SIGKILL)
|
os.kill(child.pid, signal.SIGKILL)
|
||||||
else:
|
else:
|
||||||
main_proc = psutil.Process(pid=child.pid)
|
try:
|
||||||
if hasattr(main_proc, "children"):
|
main_proc = psutil.Process(pid=child.pid)
|
||||||
child_procs = main_proc.children(recursive=True)
|
if hasattr(main_proc, "children"):
|
||||||
else:
|
child_procs = main_proc.children(recursive=True)
|
||||||
child_procs = main_proc.get_children(recursive=True)
|
else:
|
||||||
for child_proc in child_procs:
|
child_procs = main_proc.get_children(recursive=True)
|
||||||
os.kill(child_proc.pid, signal.SIGTERM)
|
for child_proc in child_procs:
|
||||||
|
os.kill(child_proc.pid, signal.SIGTERM)
|
||||||
|
except TypeError:
|
||||||
|
os.kill(child.pid, signal.SIGKILL)
|
||||||
else:
|
else:
|
||||||
os.kill(child.pid, signal.SIGTERM)
|
os.kill(child.pid, signal.SIGTERM)
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
|
|||||||
Reference in New Issue
Block a user