I\'m writing an application which needs to run a series of tasks in parallel and then a single task with the results of all the tasks run:
@celery.task
def p
The answer that @alexander-afanasiev gave you is essentially right: use a chord.
Your code is OK, but tasks.append(power.s((i, 2)))
is not actually executing the subtask, just adding subtasks to a list. It's chord(...)(...)
the one that send as many messages to the broker as subtasks you have defined in tasks
list, plus one more message for the callback subtask. When you call chord
it returns as soon as it can.
If you want to know when the chord has finished you can poll for completion like with a single task using r.ready()
in your sample.