起始芹菜工作者抛出“无属性'worker_state_db'”, [英] Start celery worker throws "no attribute 'worker_state_db'"
本文介绍了起始芹菜工作者抛出“无属性'worker_state_db'”,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试以Django应用方式启动celery worker时:
When I am trying to start celery worker in Django app as:
celery -A myApp worker -l info
我收到以下错误:
File "/home/alexander/.pyenv/versions/3.5.1/envs/myApp/lib/python3.5/site-packages/celery/utils/collections.py", line 134, in __getattr__
type(self).__name__, k))
AttributeError: 'Settings' object has no attribute 'worker_state_db'
如果您知道如何解决,请写下您的想法!
If you know how to solve it please write your idea!
推荐答案
如果在解析设置时引发异常,则会出现该错误。例如,当我们通过环境变量设置Django的 SECRET_KEY
(或其他设置)时:
The bug appears if an exception is raised while parsing settings. Such as when we set Django's SECRET_KEY
(or any other setting) via an environment variable:
SECRET_KEY = os.environ['SECRET_KEY']
要解决此问题,您可以切换回:
To solve the problem you can switch back to:
SECRET_KEY = "asdfasdfasdf"
或使用:
SECRET_KEY = os.environ.get('SECRET_KEY', '')
如果您在下面的注释中注释了以下内容,也可以找到引起问题的设置 celery.py
文件并再次启动工作程序:
You can also find which setting caused the problem if you comment our the following line in celery.py
file and start the worker again:
app.config_from_object('django.conf:settings', namespace='CELERY')
这篇关于起始芹菜工作者抛出“无属性'worker_state_db'”,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文