所以我刚刚开始使用 celery ,并尝试做一些简单的测试来感受它。
我正在尝试设置 celery 以将 postgres 用于我的后端。
在这个页面上:
http://docs.celeryproject.org/en/latest/getting-started/first-steps-with-celery.html#keeping-results
我看例子
celery = Celery('tasks', backend='redis://localhost', broker='amqp://')
所以在我的代码中我尝试
celery = Celery('tasks',
backend='sqla+postgresql://celery_exp:celery_exp@myhost/celery_exp',
broker='sqla+postgresql://celery_exp:celery_exp@myhost/celery_exp',)
但我在启动时一直收到此错误:
ImportError: No module named sqla+postgresql
在文档中我尝试了不同的变体,例如
postgresql://
postgresql+psycopg2://
我知道连接字符串是正确的,因为在 Celery 构造函数中取出后端参数按预期工作。
我在这里做错了什么?我觉得这一定是愚蠢的,因为我在网上找不到任何东西。
提前致谢。
最佳答案
答案就在这里http://celery.readthedocs.org/en/latest/configuration.html#database-url-examples
您需要在常规 SQL Alchemy url 字符串前加上 db+
,例如
CELERY_RESULT_BACKEND = "db+postgresql+psycopg2://..."
关于python - celery ,postgresql -> 配置后端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14635673/