Karl
Karl

Reputation: 3113

is it possible to manually restart celery task

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

Upvotes: 3

Views: 3237

Answers (1)

MrName
MrName

Reputation: 2529

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.

Upvotes: 3

Related Questions