Django-celery 任务由错误的运行实例提供服务

发布于 2025-01-08 06:25:02 字数 384 浏览 4 评论 0原文

我有一个 Django 应用程序,它使用 django-celery 和rabbitmq 后端。我们有一台测试机器,不同的用户在自己的帐户中运行相同的 Django 应用程序(每个用户监听不同的端口),但所有人都使用相同的 settings.py 文件,因此使用相同的rabbitmq凭据,将 celery 连接到后面-结尾。 (请注意,他们每个都使用不同的 sqlite 数据库作为数据库后端)。

我刚刚发现我们可能会在 django-celery 任务之间出现“串扰”,用户 A 帐户中的 django 应用程序发出的任务请求可能由用户 B 帐户中运行的 celery 任务提供服务。

配置避免此问题的最简单方法是什么?我需要为每个用户创建单独的rabbitmq帐户和/或虚拟主机吗?或者还有其他方法可以做到这一点吗?

I've got a Django app that uses django-celery with a rabbitmq backend. We have a test machine where different users are running the same Django app in their own accounts (each listening on a different port), but all are using identical settings.py files, and therefore the same rabbitmq credentials, to connect celery to the back-end. (Note that they're each using a different sqlite database for the db backend).

I just discovered that we may be getting "crosstalk" among the django-celery tasks, that a task request from the django app in user A's account might be being serviced by a celery task running in user B's account.

What's the simplest way to configure things to avoid this problem? Do I need to create separate rabbitmq accounts and/or vhosts for each user? Or is there some other way to do this?

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

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

发布评论

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

评论(1

娇纵 2025-01-15 06:25:02

最简单的方法是为每个环境设置单独的虚拟主机。您仍然可以共享同一个 RabbitMQ 用户。

The simplest way is to have separate vhosts for each environment. You could still share the same RabbitMQ user.

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