Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reset countdown on Celery task

I need to have a celery task run after a countdown, but be able to reset that countdown under certain conditions. For example, I want to call apply_async with countdown=15, but if certain event occurs before the task is executed, I'd like to set that countdown to 15 seconds again.

From the docs and googling I think I could accomplish this by saving the task id, and then revoking and recreating the task if the event occurs. I was wondering if there's a more elegant approach to it.

like image 416
Facundo Olano Avatar asked Mar 06 '12 23:03

Facundo Olano


1 Answers

Instead of setting the countdown can't you just revoke this task and create a new one?

like image 182
seler Avatar answered Nov 29 '22 12:11

seler