celery start导致TypeError(“unhashable type:'list'”,)

时间:2018-04-19 13:58:11

标签: python flask celery flask-socketio

我正在关注http://flask.pocoo.org/docs/0.12/patterns/celery/

的文档

我收到以下错误。

$ python ./venv/bin/celery -A app.ctasks worker -c 8 -l INFO
[2018-04-19 08:45:03,623: ERROR/MainProcess] Unrecoverable error: TypeError("unhashable type: 'list'",)
Traceback (most recent call last):
File "/Users/andy.terhune/PycharmProjects/flask_socketio_saml/venv/lib/python3.6/site-packages/kombu/utils/__init__.py", line 323, in __get__
return obj.__dict__[self.__name__]
KeyError: 'backend'

我检查了make_celery的行和后端,经纪人是包含正确数据的字符串。

celery = Celery(app.import_name, backend=app.config['CELERY_RESULT_BACKEND'], broker=app.config['CELERY_BROKER_URL'])

我的芹菜设置如下:

cinit.py

from celery import Celery

def make_celery(app):
    celery = Celery(app.import_name, backend=app.config['CELERY_RESULT_BACKEND'], broker=app.config['CELERY_BROKER_URL'])
    celery.conf.update(app.config)
    taskbase = celery.Task

    class ContextTask(taskbase):
        abstract = True

        def __call__(self, *args, **kwargs):
            with app.app_context():
                return taskbase.__call__(self, *args, **kwargs)

    celery.Task = ContextTask
    return celery

__init__.py

from flask import Flask,
from flask_socketio import SocketIO
async_mode = None

app = Flask(__name__)
app.config.from_object('config')
socketio = SocketIO(app, async_mode=async_mode)
...
from app import views, socks, saml, helper, cinit
celery = cinit.make_celery(app)
from app import ctasks

我试图以几种不同的方式开始芹菜无济于事。

python ./venv/bin/celery -A app.ctasks worker -c 8 -l INFO

导致:

Unrecoverable error: TypeError("unhashable type: 'list'",)

python ./venv/bin/celery -A app worker -c 8 -l INFO

导致:

AttributeError: 'Flask' object has no attribute 'user_options' 我在这里找到了类似的文章:AttributeError: 'Flask' object has no attribute 'user_options'

python ./venv/bin/celery -A app.cinit worker -c 8 -l INFO

导致:

AttributeError: module 'app.cinit' has no attribute 'celery' 这是我所期待的,因为我从未将芹菜设置或导入cinit.py。

1 个答案:

答案 0 :(得分:0)

有类似的问题 必须清除我的后端服务器才能使事情再次运行 在我的情况下是redis:

redis-cli FLUSHALL