1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 01:21:21 +03:00

Merge pull request #360 from matburt/fix_el6_job_cancel

Fix overall job cancel behavior
This commit is contained in:
Matthew Jones 2015-08-05 19:39:11 -04:00
commit 91bd96f458

View File

@ -23,7 +23,10 @@ import uuid
from distutils.version import LooseVersion as Version
import dateutil.parser
import yaml
import psutil
try:
import psutil
except:
psutil = None
# Pexpect
import pexpect
@ -434,11 +437,14 @@ class BaseTask(Task):
if instance.cancel_flag:
try:
if settings.AWX_PROOT_ENABLED:
if not psutil:
os.kill(child.pid, signal.SIGKILL)
else:
main_proc = psutil.Process(pid=child.pid)
if hasattr(main_proc, "children"):
child_procs = main_proc.children(recursive=False)
child_procs = main_proc.children(recursive=True)
else:
child_procs = main_proc.get_children(recursive=False)
child_procs = main_proc.get_children(recursive=True)
for child_proc in child_procs:
os.kill(child_proc.pid, signal.SIGTERM)
else: