Adding tasks to existing group or chord

时间:2017-07-20 16:15:29

标签: celery celery-task

consider following scenario;

There are 3 different type of tasks. A, B and C. A is meant to produce an input for B and B is supposed to create many C tasks after receiving an input from A.

At the start, i can only be able to define group(A, B) as Cs are executed by B. But i want to wait for all C tasks to be finished as well in order to conclude that main task is done.

Is there a way of doing that by using celery utilities?

1 个答案:

答案 0 :(得分:0)

我目前使用的解决方案是等待C内的B个任务。

喜欢的东西;

from celery.result import allow_join_result

def B():
    tasks = get_c_tasks()

    g = group(tasks)
    gr = g.apply_async()
    with allow_join_result():
        return gr.join(propagate=False)