Skip to content

Worker.timeout_task does not timeout task if recursive #72

@alexandrevicenzi

Description

@alexandrevicenzi

Worker.timeout_task interrupt subtasks if recursive is True and the task has subtasks.
The subtasks are set to INTERRUPTED but they should be set to TIMEOUT.

This is the current code of timeout_task:

    def timeout_task(self, recursive=True):
        """Set the task state to timeout."""
        try:
            self.__lock(self.worker_id, new_state=TASK_STATES["TIMEOUT"], initial_states=(TASK_STATES["OPEN"], ))
        except (MultipleObjectsReturned, ObjectDoesNotExist):
            raise Exception("Cannot interrupt task %d, state is %s" % (self.id, self.get_state_display()))

        if recursive:
            for task in self.subtasks():
                task.interrupt_task(recursive=True)
        self.logs.gzip_logs()

It's a very silly mistake, looks like it was copy and paste and someone forgot to change it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions