3

I am using celery 3 with django and flower to monitor tasks.

is there any way that if

  1. my task fail
  2. then i do some fix in code
  3. Then i get the task id and then rstart that task

Is it possible

or even a way to manually place any failed task in another queue so that it can be processes again after fixing the cause of it

2
  • You can restart the entire celery, but not a single task (a task is just a item in a queue), however you can reschedule your task for when you need, you can see how to do it here celery.readthedocs.io/en/3.0/reference/celery.task.html Commented May 2, 2016 at 13:36
  • @trinchet but i can't decide before hand when to reshedule it. Suppose there was my bad code which failed the task . I think fixed my code and then i want to retry that task Commented May 2, 2016 at 22:59

1 Answer 1

3

A bit of a hack, but what works for me is creating a new task instance with the same task ID. For example, a task with ID 'abc' runs and fails. I then "restart" the task by running:

my_task.apply_async(args=('whatever'), task_id='abc')

In reality it is less of a "restart" and more just a replacement of the original task result, but it gets the job done. Definitely open to better suggestions here as it does feel a bit clumsy.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.