From 6bccca2a9e752c68dfb2d9ddd8b823b462a43149 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Tue, 26 Aug 2014 10:20:10 -0400 Subject: [PATCH] Fix an issue where canceling jobs could leave orphaned and dead ansible-playbook processes --- awx/main/tasks.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index aae063a013..84dfbedf54 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -9,6 +9,7 @@ from distutils.version import StrictVersion as Version import json import logging import os +import signal import pipes import re import stat @@ -340,7 +341,10 @@ class BaseTask(Task): # Refresh model instance from the database (to check cancel flag). instance = self.update_model(instance.pk) if instance.cancel_flag: - child.terminate(canceled) + os.kill(child.pid, signal.SIGINT) + time.sleep(3) + # The following line causes orphaned ansible processes + # child.terminate(canceled) canceled = True if idle_timeout and (time.time() - last_stdout_update) > idle_timeout: child.close(True)