我有一个简单的项目,没有任何框架,如Django或Flask。
我的配置是这样的:
CELERY_BROKER_BACKEND = "sqlakombu.transport.Transport"
CELERY_BROKER_URL = "db+sqlite:///results.sqlite"
CELERY_CACHE_BACKEND = "db+sqlite:///results.sqlite"
CELERY_RESULT_BACKEND = "db+sqlite:///results.sqlite"
我已经安装了包:
SQLAlchemy==1.2.8
kombu==4.2.0
kombu-sqlalchemy==1.1.0
celery==4.1.1
当我尝试开始吃芹菜时:
celery worker -A proj --loglevel=info
我收到了这个错误:
File "/home/cyildiz/Projects/env/sample/local/lib/python2.7/site-packages/kombu/connection.py", line 582, in get_transport_cls
transport_cls = get_transport_cls(transport_cls)
File "/home/cyildiz/Projects/env/sample/local/lib/python2.7/site-packages/kombu/transport/__init__.py", line 83, in get_transport_cls _transport_cache[transport] = resolve_transport(transport)
File "/home/cyildiz/Projects/env/sample/local/lib/python2.7/site-packages/kombu/transport/__init__.py", line 64, in resolve_transport
raise KeyError('No such transport: {0}'.format(transport))
KeyError: u'No such transport: db'
当我将设置更改为:
CELERY_BROKER_BACKEND = "sqlakombu.transport.Transport"
CELERY_BROKER_URL = "sqla+sqlite:///results.sqlite"
CELERY_CACHE_BACKEND = "sqla+sqlite:///results.sqlite"
CELERY_RESULT_BACKEND = "sqla+sqlite:///results.sqlite"
错误是:
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module__import__(name)
ImportError: No module named sqla
那么,我在哪里犯这个错误?
答案 0 :(得分:1)
好吧,CELERY_BROKER_URL犯了这个错误,我删除了该行,并将设置设为:
CELERY_BROKER_BACKEND = "db+sqlite:///celery.sqlite"
CELERY_CACHE_BACKEND = "db+sqlite:///celery.sqlite"
CELERY_RESULT_BACKEND = "db+sqlite:///celery.sqlite"
现在可行。