Skip to content

[FEATURE] Option to retry a failed task #1348

Open

Description

@eriktelepovsky

Hi

Is your feature request related to a problem? Please describe.
I'm always frustrated when I need to manually execute a script to retry a failed task. I know there is a possibility to setup a failover and retry strategy, but sometimes it is more suitable to retry the task immediately on demand.

Describe the solution you'd like
It would be great if there is a button in the UI for the failed task to retry it. It would execute the task with the same parameters.

Describe alternatives you've considered
There is a django-celery-results app alternative which I can add a custom action to retry the specific tasks, but flower is much better tool. The only missing thing is the "retry button".

Additional context
Snippet I currently use:

def retry_task(task_id):    
    meta = celery_app.backend.get_task_meta(task_id)
    task = celery_app.tasks[meta['name']]
    task.apply_async(args=meta['args'], kwargs=meta['kwargs'])

Thank you in advance!

Activity

  1. dgarciams2s commented on Feb 5, 2024

    @dgarciams2s

    It would be great, really

  2. iamliamc commented on Jul 26, 2024

    @iamliamc

    I agree this would be really useful

  3. kooshan75 commented on Sep 17, 2024

    @kooshan75

    Need this too, it'd be much appreciated.

  4. iamliamc commented on Sep 17, 2024

    @iamliamc

    I ended up with something like this:

        def retry_task(self, task_id: str) -> AsyncResult:
            meta = self.celery_app.backend.get_task_meta(task_id)  # type: ignore
            task = self.celery_app.tasks[meta["name"]]
            results = task.apply_async(args=meta["args"], kwargs=meta["kwargs"])
            return AsyncResult(
                id=results.id,
                name=results.name,
                status=results.status,
                result=results.result,
                traceback=results.traceback,
                args=results.args,
                kwargs=results.kwargs,
                date_done=results.date_done,
            )
    
  5. iloveitaly commented on Jan 21, 2025

    @iloveitaly

    Looks like #1417 solves this problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions