6👍
✅
You can call other_task.delay()
from inside Randomer.run
; in this case you may want to set Randomer.ignore_result = True
(and other_task.ignore_result
, and so on).
Remember that celery tasks delay
returns instantly, so if you don’t put any limit or wait time on the nested calls (or recursive calls), you can reach meltdown pretty quickly.
Instead of recursion or nested tasks, you should consider an infinite loop to avoid stack overflow (no pun intended).
from celery.task import Task
class Randomer(Task):
def run(self, **kwargs):
while True:
do_something(**kwargs)
time.sleep(600)
2👍
You can chain subtasks as described here: http://docs.celeryproject.org/en/latest/userguide/canvas.html#chains
- [Django]-Is it a bad practice to use sleep() in a web server in production?
- [Django]-Docker setting up gdal for django
Source:stackexchange.com