Celery tries to connect to the wrong broker

拟墨画扇 提交于 2019-12-05 09:46:42

import your celery and add your broker like that :

celery = Celery('task', broker='redis://127.0.0.1:6379')
celery.config_from_object(celeryconfig)

If you followed First Steps with Celery tutorial, specifically:

app.config_from_object('django.conf:settings', namespace='CELERY')

then you need to prefix your settings with CELERY, so change your BROKER_URL to:

CELERY_BROKER_URL = 'redis://127.0.0.1:6379'

I got this response because I was starting my celery worker incorrectly on the terminal.

I was running:

celery -A celery worker

But because I defined celery inside of web/server.py, I needed to run:

celery -A web.server.celery worker

web.server indicates that my celery object is in a file server.py inside a directory web. Running that latter command connected to the broker I specified!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!