I maybe using celery incorrectly. But the chatbot I am developing requires celery with redis for async tasks. This is the framework I am using: http://microsoftbotframework.readthedocs.io/en/latest/asynctasks/.
My particular use case currently requires me to run a celery task forever and wait for some arbitrary amount of time in between, which ranges from 30 minutes to 3 days. Something like this
@celery.task
def myAsyncMethod():
while true:
timeToWait = getTimeToNextAlarm()
sleep(timeToWait)
sendOutMessages()
Basically, I have an async process which never exits. I am pretty sure shouldn't be using celery like this. So my question is, how do I create a celery task which processes the first task, spawns a task and submits it to celery queue and exits. Basically, something like this:
@celery.task
def myImprovedTask():
timeToWait = getTimeToNextAlarm()
sleep(timeToWait)
sendOutMessages()
myImprovedTask().delay() # recursive call to async method for next event
Not necessarily recursive or even like this, but something which is the way celery originally is intended to be used (for short lived tasks I believe?)
Tl;dr: How do I create a celery task from within another task and make the original task exit?
Do tell if I should explain it further. Thanks.