python - celery ,postgresql -> 配置后端

标签 python celery backend

所以我刚刚开始使用 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/

相关文章:

python - 在 Windows 上安装 Airflow

python - 如何使用 celery-beat 启动任务?

mongodb - 如何在 MongoDB 中获取并按日期范围-每周-进行分组?

python - 尝试使用不带 POST 的 Microsoft Graph API 来获取不记名 token

python - 在 Python 中使用 deepcopy 引用子对象的位置

python - 从 celery 导入 current_app 会给出 ValueError : attempted relative import beyond top-level package

forms - Magento,在网格和表单后端添加并设置一个复选框

javascript - Facebook 如何将 Like 按钮连接到您的 FB 帐户

从不处理信号的 bash 脚本中调用的 Python 脚本

网络应用程序中的 Python(客户端)