请帮我解决这个问题 我在运行时遇到了这个问题
celery -A app.celery worker --loglevel=info
错误:
Unable to load celery application.
The module app.celery was not found.
我的代码是——
# Celery Configuration
from celery import Celery
from app import app
print("App Name=",app.import_name)
celery=Celery(app.name,broker=app.config['CELERY_BROKER_URL'])
celery.conf.update(app.config)
@celery.task
def download_content():
return "hello"
目录结构--
newYoutube/app/auth/routes.py 并且此功能存在于 routes.py 中
auth 是蓝图。
最佳答案
通过调用 celery 时
celery -A app.celery ...
celery 将在
celery
命名空间中查找名称 app
,期望它包含 Celery
的实例。如果你把它放在别处(比如,在 app.auth.routes
中),那么 celery 将找不到它。我有一个工作示例,您可以从 https://github.com/davewsmith/flask-celery-starter 中获取
或者,引用 Flask Mega Tutorial 的第 22 章,它使用
rx
而不是 celery
,但构建代码的一般方法是相似的。
关于python - flask 错误 : Unable to load celery application,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59472600/