V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
bmos
V2EX  ›  Python

Flask Celery 异步任务配置 backend 还是报错 AttributeError: 'DisabledBackend' object has no attribute '_get_task_meta_for'

  •  
  •   bmos · 2019-04-12 15:09:51 +08:00 · 3648 次点击
    这是一个创建于 1841 天前的主题,其中的信息可能已经有所发展或是发生改变。

    问题很明显,网上搜到的结果也都是说配置 backend,但是我觉得已经配置上了 首先用的是《深入理解 Flask 》中的例子,用 rabbitmq,报错。

    CELERY_BROKER_URL = "amqp://guest:guest@localhost:5672//"  
    CELERY_BACKEND_URL = "amqp://guest:guest@localhost:5672//"
    

    启动后显示

    • ** ---------- [config]
    • ** ---------- .> app: webapp:0x7fb0f99e40b8
    • ** ---------- .> transport: amqp://guest:**@localhost:5672//
    • ** ---------- .> results: amqp://
    • *** --- * --- .> concurrency: 12 (prefork) -- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker) --- ***** ----- -------------- [queues] .> celery exchange=celery(direct) key=celery

    尝试了 redis
    CELERY_BROKER_URL = "redis://localhost:6379/0"
    CELERY_BACKEND_URL = "redis://localhost:6379/0"
    启动后显示

    • ** ---------- [config]
    • ** ---------- .> app: webapp:0x7f91ac94b668
    • ** ---------- .> transport: redis://localhost:6379/0
    • ** ---------- .> results: redis://localhost:6379/0
    • *** --- * --- .> concurrency: 12 (prefork) -- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker) --- ***** ----- -------------- [queues] .> celery exchange=celery(direct) key=celery

    毫无意外都是显示 DisabledBackend 错误

    按照我的尿性,通常会打错字母,这次已经看了一天了,没有错字母。只能发个帖求助。╮(╯▽╰)╭,各位大佬走过路过看一看。

    第 1 条附言  ·  2019-04-12 15:53:55 +08:00
    每次发完贴后就感觉如有神助,似乎找到办法了,改一下配置方式:
    app.config['CELERY_RESULT_BACKEND'] = 'redis://localhost:6379/0'

    celery = Celery(app.name, broker=app.config['CELERY_BROKER_URL'])

    celery.conf.update(app.config)
    对比原先内容为:
    app.config['CELERY_BACKEND_URL'] = 'redis://localhost:6379/0'

    celery = Celery(app.name, broker=app.config['CELERY_BROKER_URL'],backend=app.config['CELERY_BACKEND_URL'] = 'redis://localhost:6379/0')

    celery.conf.update(app.config)
    网上找到的大部分资料都是原先的方式,昨天也配置过 CELERY_RESULT_BACKEND,但是没有成功。。 具体原因出在哪里不深究了,大概率版本问题吧,先用上再说。
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2901 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 03:10 · PVG 11:10 · LAX 20:10 · JFK 23:10
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.