【问题标题】:Flask Error: Unable to load celery application烧瓶错误:无法加载芹菜应用程序
【发布时间】:2020-04-15 18:17:48
【问题描述】:

请帮我解决这个问题,我在跑步时遇到了这个问题

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 是蓝图。

【问题讨论】:

    标签: python python-3.x flask celery celery-task


    【解决方案1】:

    通过调用 celery 时

    celery -A app.celery ...
    

    celery 将在 app 命名空间中查找名称 celery,期望它包含 Celery 的实例。如果你把它放在其他地方(比如,app.auth.routes),那么 celery 就找不到它。

    我有一个工作示例,您可以从 https://github.com/davewsmith/flask-celery-starter 那里借鉴

    或者,参考Flask Mega Tutorial的第22章,它使用rx而不是celery,但构造代码的一般方法是相似的。

    【讨论】:

      猜你喜欢
      • 2018-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-23
      • 1970-01-01
      • 2016-12-23
      • 1970-01-01
      相关资源
      最近更新 更多