gpt4 book ai didi

python - Django Celery - 无法连接到 amqp ://guest@127. 0.0.8000:5672//

转载 作者:IT老高 更新时间:2023-10-28 22:00:36 24 4
gpt4 key购买 nike

我正在尝试设置 Django-Celery。我正在学习教程

http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html

当我运行时 $ python manage.py celery worker --loglevel=info

我明白了

[Tasks]


/Users/msmith/Documents/dj/venv/lib/python2.7/site-packages/djcelery/loaders.py:133: UserWarning: Using settings.DEBUG leads to a memory leak, never use this setting in production environments!
warnings.warn('Using settings.DEBUG leads to a memory leak, never '

[2013-08-08 11:15:25,368: WARNING/MainProcess] /Users/msmith/Documents/dj/venv/lib/python2.7/site-packages/djcelery/loaders.py:133: UserWarning: Using settings.DEBUG leads to a memory leak, never use this setting in production environments!
warnings.warn('Using settings.DEBUG leads to a memory leak, never '

[2013-08-08 11:15:25,369: WARNING/MainProcess] celery@sfo-mpmgr ready.
[2013-08-08 11:15:25,382: ERROR/MainProcess] consumer: Cannot connect to amqp://guest@127.0.0.1:5672/celeryvhost: [Errno 61] Connection refused.
Trying again in 2.00 seconds...

以前有人遇到过这个问题吗?

settings.py

# Django settings for summertime project.
import djcelery
djcelery.setup_loader()

BROKER_URL = 'amqp://guest:guest@localhost:5672/'

...

INSTALLED_APPS = {
...
'djcelery',
'celerytest'
}

wsgi.py

import djcelery
djcelery.setup_loader()

最佳答案

2022 年 1 月更新:此答案已过时。如评论建议,请引用this link

问题是您正在尝试连接到 RabbitMQ 的本地实例。查看您的 settings.py

中的这一行
BROKER_URL = 'amqp://guest:guest@localhost:5672/'

如果您目前正在进行开发工作,您可以避免设置 Rabbit 及其周围的所有困惑,而只需使用带有 Django 数据库的消息队列的开发版本。

通过将之前的配置替换为:

BROKER_URL = 'django://'

...并添加此应用程序:

INSTALLED_APPS += ('kombu.transport.django', )

最后,启动worker:

./manage.py celery worker --loglevel=info

来源:http://docs.celeryproject.org/en/latest/getting-started/brokers/django.html

关于python - Django Celery - 无法连接到 amqp ://guest@127. 0.0.8000:5672//,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18133249/

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