【发布时间】:2013-11-12 19:58:48
【问题描述】:
我的问题与this one 重复,但更详细。
问题是我在我的 Celery 配置文件中设置了 BROKER_URL,但这并没有反映在我 am 加载配置中:我检查过,它 是 正在加载 - 事实上,那里定义的其他常量正在被设置,只是不是 BROKER_URL。
这似乎是一个错误,但我想确定一下。
celeryconfig.py:
BROKER_URL = "amqp://user:password@remote.server.com:5672//vhost"
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_ENABLE_UTC = True
(JSON 被用作序列化程序,而不是 Pickle,所以我知道这是有效的。)
app.py:
from celery import Celery
app = Celery('tasks', broker='amqp://guest@localhost//')
app.config_from_object('celeryconfig')
调用 Worker:
celery -A app.app worker -l info
但后来我明白了:
[2013-11-12 11:20:51,610: INFO/MainProcess] consumer: Connected to amqp://guest@127.0.0.1:5672//.
我尝试分手BROKER_URL,但无济于事:
BROKER_TRANSPORT = 'amqp'
BROKER_USER = 'user'
BROKER_PASSWORD = 'password'
BROKER_HOST = 'remote.server.com'
BROKER_PORT = 5672
BROKER_VHOST = '/vhost'
有趣的是,当我在app.py 中明确设置BROKER_URL 时,它确实有效:
from celery import Celery
app = Celery('tasks', broker='amqp://guest@localhost//')
app.config_from_object('celeryconfig')
app.conf.BROKER_URL = "amqp://user:password@remote.server.com:5672//vhost"
【问题讨论】:
-
请注意,拆分代理 url 已被弃用,并将在 celery 4 中删除:celery.readthedocs.org/en/latest/internals/deprecation.html
标签: celery config configuration-files