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

Fix an issue where a well timed cancel could try to cancel a job right

after it has finished causing an error.
This commit is contained in:
Matthew Jones 2015-05-18 10:18:36 -04:00
parent d46d9bb7f4
commit 472f086862

View File

@ -393,11 +393,12 @@ class BaseTask(Task):
# Refresh model instance from the database (to check cancel flag).
instance = self.update_model(instance.pk)
if instance.cancel_flag:
os.kill(child.pid, signal.SIGINT)
time.sleep(3)
# The following line causes orphaned ansible processes
# child.terminate(canceled)
canceled = True
try:
os.kill(child.pid, signal.SIGINT)
time.sleep(3)
canceled = True
except OSError:
logger.warn("Attempted to cancel already finished job, ignoring")
if idle_timeout and (time.time() - last_stdout_update) > idle_timeout:
child.close(True)
canceled = True