使用 Celery 和 RabbitMQ 的简单队列

发布于 2024-10-01 22:19:06 字数 222 浏览 1 评论 0原文

我正在尝试实现一个一次执行一项任务的简单队列。使用 Celery 从主线程卸载任务并在 Celery 配置中设置 concurrency=1 效果很好,但我可能想使用更多并发工作线程来执行其他任务。

有没有办法告诉 Celery 或 RabbitMQ 不要使用多个并发工作线程来执行任务(除非强制 concurrency=1)?我在文档中找不到任何内容,但也许这些工具不是为线性队列设计的?

谢谢!

I'm trying to implement a simple queue that performs one task at a time. Offloading tasks off the main thread using Celery and setting concurrency=1 in the Celery config works fine, but I might want to use more concurrent workers for other tasks.

Is there a way to tell Celery or RabbitMQ to not use multiple concurrent workers for a task (except by forcing concurrency=1)? I can't find anything in the documentation but maybe these tools are not designed for a linear queue?

Thanks!

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

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

发布评论

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

评论(1

金橙橙 2024-10-08 22:19:06

我认为您需要的是每种类型的任务都有一个单独的队列。创建从每个队列进行消费的单独工作线程,并发度设置为 1。

I think what you need is a separate queue for each type of task. Create separate workers that consume from each queue, with concurrency set to 1.

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