Celery 是否结合链和组使用结果后端?
Does Celery use result backend in combination of chain and group?
在我的 python 项目中,我想使用 celery 来创建任务管道:一些任务将被分组,这个组是链的一部分。管道架构:
task_chain = chain(
group(
chain(taks1.s(uid=uid, index=i), task2.s(uid=uid, index=i)) for i in
range(len(collection))
),
task3.s(uid=uid),
task4.s(uid=uid),
reduce_job_results_from_pages.s(job_uid=job_uid),
push_metrics.s(job_uid=job_uid))
在这种情况下我应该使用结果后端还是只使用代理就足够了?
我不明白芹菜使用什么技术来同步任务结果并将上一个任务或一组任务的结果传递给链中的下一个任务。
谢谢!
Canvas 页面的 Important Notes 部分提供了一些答案:
Tasks used within a chord must not ignore their results. In practice this means that you must enable a result_backend in order to use chords. Additionally, if task_ignore_result is set to True in your configuration, be sure that the individual tasks to be used within the chord are defined with ignore_result=False. This applies to both Task subclasses and decorated tasks.
您可能想知道,既然您不使用和弦,那么没有它也能逃脱。 - 我相信 Celery 会将任何带有 Group 的 Chain 转换为 Chord。
在我的 python 项目中,我想使用 celery 来创建任务管道:一些任务将被分组,这个组是链的一部分。管道架构:
task_chain = chain(
group(
chain(taks1.s(uid=uid, index=i), task2.s(uid=uid, index=i)) for i in
range(len(collection))
),
task3.s(uid=uid),
task4.s(uid=uid),
reduce_job_results_from_pages.s(job_uid=job_uid),
push_metrics.s(job_uid=job_uid))
在这种情况下我应该使用结果后端还是只使用代理就足够了? 我不明白芹菜使用什么技术来同步任务结果并将上一个任务或一组任务的结果传递给链中的下一个任务。
谢谢!
Canvas 页面的 Important Notes 部分提供了一些答案:
Tasks used within a chord must not ignore their results. In practice this means that you must enable a result_backend in order to use chords. Additionally, if task_ignore_result is set to True in your configuration, be sure that the individual tasks to be used within the chord are defined with ignore_result=False. This applies to both Task subclasses and decorated tasks.
您可能想知道,既然您不使用和弦,那么没有它也能逃脱。 - 我相信 Celery 会将任何带有 Group 的 Chain 转换为 Chord。