Django/Celery:除非重新启动,否则 celeryd 不会从队列中检索新任务

发布于 2024-12-05 08:06:49 字数 914 浏览 1 评论 0原文

我不明白为什么 celeryd 没有拉取添加到队列中的新任务。它只会在启动后检索任务,然后无法监视。我正在使用 Django ORM 作为消息代理,通过 django-celery 运行 Django 开发服务器。

我的 Django 设置文件具有以下 celery 配置:

INSTALLED_APPS += ("djcelery", )
INSTALLED_APPS += ("djkombu", )

import djcelery
djcelery.setup_loader()
BROKER_TRANSPORT = "djkombu.transport.DatabaseTransport"

BROKER_HOST = "localhost"
BROKER_PORT = 5672
BROKER_USER = "guest"

BROKER_PASSWORD = "guest"
BROKER_VHOST = "/"

此外,如果重要的话,我使用远程 MySQL 服务器作为我的数据库后端。

编辑:已解决!

花了几个小时解决这个问题后,我在 Celery 常见问题解答中找到了答案:

MySQL 抛出死锁错误,我能做什么?

我没有在日志中看到死锁错误,但是修改我的/etc/my.cnf 包含:

[mysqld]
transaction-isolation = READ-COMMITTED

解决了我的问题。

希望这对其他人有帮助!

I cannot figure out why celeryd is not pulling new tasks that are added to the queue. It will only retrieve tasks once it is started, then fails to monitor thereafter. I am running the Django development server with django-celery using the Django ORM for the message broker.

My Django settings file has this configuration for celery:

INSTALLED_APPS += ("djcelery", )
INSTALLED_APPS += ("djkombu", )

import djcelery
djcelery.setup_loader()
BROKER_TRANSPORT = "djkombu.transport.DatabaseTransport"

BROKER_HOST = "localhost"
BROKER_PORT = 5672
BROKER_USER = "guest"

BROKER_PASSWORD = "guest"
BROKER_VHOST = "/"

Furthermore if it matters, I am using a remote MySQL server as my database backend.

Edit: Resolved!

After spending several hours on this, I found an answer in the Celery FAQ:

MySQL is throwing deadlock errors, what can I do?

I wasn't seeing the deadlock errors in the log, but modifying my /etc/my.cnf to include:

[mysqld]
transaction-isolation = READ-COMMITTED

resolved my issue.

Hope this helps someone else!

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

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

发布评论

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

评论(1

少女的英雄梦 2024-12-12 08:06:49

花了几个小时研究这个问题后,我在 Celery FAQ 中找到了答案:

MySQL 抛出死锁错误,我该怎么办?

我没有在日志中看到死锁错误,而是修改我的 /etc/my.cnf 以包括:

[mysqld]
transaction-isolation = READ-COMMITTED

解决了我的问题。

希望这对其他人有帮助!

After spending several hours on this, I found an answer in the Celery FAQ:

MySQL is throwing deadlock errors, what can I do?

I wasn't seeing the deadlock errors in the log, but modifying my /etc/my.cnf to include:

[mysqld]
transaction-isolation = READ-COMMITTED

resolved my issue.

Hope this helps someone else!

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