如何延迟/推迟 Gearman 工作?

发布于 2024-12-22 19:36:44 字数 342 浏览 1 评论 0原文

我正在使用 gearman 来同步不同服务器上的数据。我们有 1 个主服务器,例如 10 个本地服务器。让我描述一种可能的情况。假设,gearman 开始工作,并且完成了 5 个作业,这 5 个服务器上的数据已同步。例如,当开始执行下一项工作时,我们失去了与服务器的连接,并且现在不可用。按照gearman的逻辑,它会一次又一次地重试。因此,剩余的作业(对于服务器 7、8、9、10)将不会执行,直到第 6 个作业尚未完成。最好的解决方案是推迟作业并将其放入队列末尾并继续作业 7-10 的工作。

如果有人知道如何做到这一点,请发布方法。

PS:我用的是Python。

I'm using gearman for synchronizing data on different servers. We have 1 main server and, for example, 10 local servers. Let me describe one of possible situations. Say, gearman started working, and 5 jobs are done, data on that 5 servers is synced. When doing the next job is started, say, we lost the connection with server and it's not available right now. By the logic of gearman it retries again and again. So the remaining jobs (for servers 7, 8, 9, 10) will not be executed until the 6th is not done. The best solution would be postponing the job and putting it to the end of queue and continuing work of jobs 7-10.

If someone do know how to do that, please post the way.

PS: I'm using python.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

垂暮老矣 2024-12-29 19:36:44

Gearman 作业可以并行或串行运行。您应该使用并发作业(每个服务器一个),而不是使用单个作业。

Gearman jobs can run in parallel or series. Instead of using single jobs, you should use concurrent jobs (one for each server).

走野 2024-12-29 19:36:44
GearmanClient.submit_multiple_jobs(jobs_to_submit, background=False, wait_until_complete=True, max_retries=0, poll_timeout=None)

这个功能会有帮助。只要让背景 = True 即可。

此链接也会有所帮助。

GearmanClient.submit_multiple_jobs(jobs_to_submit, background=False, wait_until_complete=True, max_retries=0, poll_timeout=None)

This function will help. Just let background = True.

This link will help, too.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文