Skip to content

Commit

Permalink
Skip running task if it is in any of the complete states
Browse files Browse the repository at this point in the history
  • Loading branch information
goosemania committed May 17, 2021
1 parent b5031a2 commit 41e3106
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions server/pulp/server/async/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,15 @@ def __call__(self, *args, **kwargs):
This overrides PulpTask's __call__() method. We use this method
for task state tracking of Pulp tasks.
"""
# Check task status and skip running the task if task state is 'canceled'.
# Check task status and skip running the task if task state is in one of complete states.
try:
task_status = TaskStatus.objects.get(task_id=self.request.id)
except DoesNotExist:
task_status = None
if task_status and task_status['state'] == constants.CALL_CANCELED_STATE:
_logger.debug("Task cancel received for task-id : [%s]" % self.request.id)
if task_status and task_status['state'] in constants.CALL_COMPLETE_STATES:
_logger.debug(
"Task is in the %s state, task-id : [%s]" % (task_status['state'], self.request.id)
)
return
# Update start_time and set the task state to 'running' for asynchronous tasks.
# Skip updating status for eagerly executed tasks, since we don't want to track
Expand Down

0 comments on commit 41e3106

Please sign in to comment.