我正在使用带有 redis 的芹菜服务器作为经纪人和烧瓶。
烧瓶服务器运行后,我启动芹菜工作器(按 celery -E -A app.celery worker
(,但收到以下错误:
Process SpawnPoolWorker-115:
Traceback (most recent call last):
File "c:usersaappdatalocalprogramspythonpython36libsite-packageskombuutilsobjects.py
return obj.__dict__[self.__name__]
KeyError: 'default_modules'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:usersaappdatalocalprogramspythonpython36libsite-packageskombuutilsobjects.py
return obj.__dict__[self.__name__]
KeyError: 'data'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:usersaappdatalocalprogramspythonpython36libsite-packagesbilliardprocess.py",
self.run() [.....]
File "c:usersaappdatalocalprogramspythonpython36libsite-packagesceleryapputils.py",
for key in sorted(really_left)
celery.exceptions.ImproperlyConfigured:
Cannot mix new setting names with old setting names, please
rename the following settings to use the old format:
include -> CELERY_INCLUDE
Or change all of the settings to use the new format :)
但是我没有使用设置名称include
或CELERY_INCLUDE
...
celery = Celery(
imports=app.import_name,
result_backend=app.config['CELERY_RESULT_BACKEND'],
broker_url=app.config['BROKER_URL']
)
此错误可能来自哪里?
http://flask.pocoo.org/docs/1.0/patterns/celery/的建议进行操作使舒尔删除函数make_celery(app)
中的celery.conf.update(app.config)
。该错误将不再显示。
当您使用 2 种方式更新芹菜配置时,会出现此错误,例如
1.
celery.conf.update()
和
阿拉伯数字。
celery.conf.task_routes = {
'taskname': {'queue': 'celery'}
}
只遵循一种方式
最佳做法是将所有配置保留在 celeryconfig.py 文件中,并在 Celery 应用程序中导入
样品 celeryconfig.py
broker_url = 'redis://localhost:6379/0'
result_backend = 'redis://localhost:6379/0'
task_serializer = 'json'
result_serializer = 'json'
accept_content = ['json']
timezone = 'Asia/Kolkata'
enable_utc = True
app.py
import celeryconfig
celery = Celery()
celery.config_from_object(celeryconfig)
希望这能解决您的问题
在此处签出新的小写设置以新格式编写配置