在我的 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))
在这种情况下我应该使用结果后端还是仅代理就足够了? 我不明白 celery 使用什么技术来同步任务结果并将前一个任务或一组任务的结果传递到链中的下一个任务。
谢谢!
最佳答案
Important Notes 中提供了一些答案。 Canvas 页面上的部分:
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.
您可能想知道没有它是否可以摆脱困境,因为您不使用 Chord。 - 我相信 Celery 会将任何带有组的链转变为和弦。
关于python - Celery是否使用链和组组合的结果后端?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62001024/