这是我的芹菜文件:
#Celery stuff
BROKER_URL = 'redis://localhost:6379'
CELERY_RESULT_BACKEND = 'redis://localhost:6379'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
在我的settings.py中我有这个:
- ** ---------- [config]
- ** ---------- .> app: default:0x1052af590 (.default.Loader)
- ** ---------- .> transport: amqp://guest:**@localhost:5672//
- ** ---------- .> results: disabled://
- *** --- * --- .> concurrency: 8 (prefork)
但是在运行celeryd时会发生这种情况:
import djcelery
djcelery.setup_loader()
BROKER_HOST = 'localhost'
BROKER_PORT = 6379
BROKER_USER = 'guest'
BROKER_PASSWORD = 'guest'
BROKER_VHOST = '/'
BROKER_URL = 'redis://localhost:6379'
CELERY_RESULT_BACKEND = 'redis://localhost:6379'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
它似乎并没有使用我提供的配置。我错过了什么?
编辑:评论建议我使用djcelery:
{{1}}
即使运行此celeryd仍然默认为5672
答案 0 :(得分:0)
我认为您忘记了在config_from_object方法中指定namespace
属性。
因此,您需要替换此
app.config_from_object("django.conf:settings", namespace="CELERY")
与
app.config_from_object("django.conf:settings")