5👍
✅
Short version, yes you’re doing the right thing here.
Long version:
The thing is that you don’t want something like this:
@task
def something(**kwargs):
# do something here
something_else.delay().get()
@task
def something_else(**kwargs):
# do something else here
pass
Which will make something
wait for the result from something_else
.
You could even consider moving the creating of the message to a task (so your loop only spawns tasks and doesn’t connect to the database straight away).
PS: if you want to keep track of all the results from the result of the ProcessRequests
task you could execute these as subresults: http://docs.celeryproject.org/en/latest/userguide/canvas.html?highlight=asyncresult#subtasks
It can help you group the results: http://docs.celeryproject.org/en/latest/userguide/canvas.html?highlight=asyncresult#group-results
Source:stackexchange.com