How to postpone a task using Celery?

Doesn't talk about the delay method.

I want to be able to get the task given its task_id and change its ETA on the fly before it is completed.

Now I have to cancel it and rewrite it. It is difficult if the planned process involves many things.

+6
python django celery
source share
2 answers

You must keep some pause out of the celery / task queue. I do this using an email program that uses celery. I can pause parts of the system by setting values ​​in memcache or mysql. Then the tasks are performed to request an external resource before the task is completed. If this means that it is paused, it sets what task.retry () is doing, which causes it to pass the retry delay time, etc.

+1
source share

Assuming you are using django-celery and PeriodicTask with DatabaseScheduler, you need to change the PeriodicTask or crontab interval and save it. If your task is determined by the interval, change the last_run_at property.

You start celerybeat with the database scheduler with:

 python manage.py celerybeat -S djcelery.schedulers.DatabaseScheduler 
+1
source share

All Articles