def mark_finished(self, exit_code=None, lost=False):
"""
Update the execution status after it has finished:
successfully, in error, or because it was lost.
Also update the task and workflow; re-queue the task if
it should be retried.
"""
if lost:
self.status = Execution.LOST
self.task.enqueue()
elif exit_code == 0:
self.task.status = Task.SUCCEEDED
self.status = Execution.SUCCEEDED
else:
# queue another run if there are remaining retries
# (current execution is not in count b/c it hasn't been saved yet)
failed_count = self.task.execution_set.filter(status=Task.FAILED).count()
if failed_count < self.task.template.max_retries:
self.task.enqueue()
else:
self.task.status = Task.FAILED
self.status = Execution.FAILED
if self.task.status != Task.RUNNING:
self.task.save()
with transaction.atomic():
self.task.update_downstream()
if self.task.run:
self.task.run.update_status()
self.stop_timestamp = functions.Now()
# need to be careful not to overwrite stdout/stderr
self.save(update_fields=['status', 'stop_timestamp'])
评论列表
文章目录