gpt4 book ai didi

python - 使用大型 ETA 调度 celery 任务

转载 作者:行者123 更新时间:2023-12-03 06:36:17 24 4
gpt4 key购买 nike

我目前正在使用 ETA 在 celery 中试验 future 的任务功能和 redis 代理。使用 redis 代理的已知问题之一与 visibility timeout 有关。 :

If a task isn’t acknowledged within the Visibility Timeout the task will be redelivered to another worker and executed.

This causes problems with ETA/countdown/retry tasks where the time to execute exceeds the visibility timeout; in fact if that happens it will be executed again, and again in a loop.


我可以设想的一些任务将在几周/几个月的时间尺度上有一个 ETA。设置 visibility timeout大到足以涵盖这些任务可能是不明智的。
是否有任何方法可以使用 redis 代理处理这些任务?我知道 this question .更换经纪人是唯一的选择吗?

最佳答案

我通过以下方式使用 redis 执行此操作:
我们的客户可以安排发布他们的某些内容。我们将发布与应该执行的时间一起存储在我们的数据库中。
然后我们使用 celery beat 执行周期性任务(每小时或适合您的任务),检查我们的发布表中是否有计划在下一个时间段内(再次小时或适合您的内容)的发布。如果找到,我们会用 celery 为他们安排一项任务。这允许我们有一个短的 ETA。

关于python - 使用大型 ETA 调度 celery 任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45516963/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com