From fc5c97d9ea9e2de90f3a7386a63eb13a5402f811 Mon Sep 17 00:00:00 2001 From: Chris Church Date: Thu, 21 Nov 2013 17:58:36 -0500 Subject: [PATCH] AC-620 Continue to update status while a task is running, so that long running tasks don't get inadvertently canceled. --- awx/main/tasks.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 4ec74a1ef3..f12451d41f 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -193,10 +193,11 @@ class BaseTask(Task): #task_stdout_handle.write(logfile.getvalue()[old_logfile_pos:logfile_pos]) #task_stdout_handle.flush() last_stdout_update = time.time() - instance = self.get_model(instance.pk) - # Commit transaction needed when running unit tests. FIXME: Is it - # needed or breaks anything for normal operation? - transaction.commit() + # Update instance status here (also updates modified timestamp, so + # we have a way to know the task is still running, otherwise the + # post_run_hook below would cancel long-running tasks that are + # really still active). + instance = self.update_model(instance.pk, status='running') if instance.cancel_flag: child.close(True) canceled = True