python - Celery Cloudamqp 为每个任务创建新连接

标签 python django celery django-celery cloudamqp

我目前正在使用 nitrous.io 运行 Django 和 Celery,然后使用 Cloudamqp 作为我的免费计划代理(最多 3 个连接)。我能够正常连接并正常启动周期性任务。

当我运行时

    celery -A proj worker  -l info   

2 个连接立即在 Cloudamqp 上创建,我能够在第 3 个连接上手动创建多个任务,一切都很好。但是,当我用

运行 celery beat 时
    celery -A proj worker -B -l info

所有 3 个连接都已使用,如果 celery beat 创建了 1 个或多个新任务,则会创建另一个第 4 个连接,从而超过允许的最大连接数。

我试过了,目前已经设置好了

    BROKER_POOL_LIMIT = 1

但这似乎并没有限制连接 我也试过

    celery -A proj worker -B -l info
    celery -A proj worker -B -l info -c 1  
    celery -A proj worker -B -l info --autoscale=1,1  -c 1  

没有运气。

为什么立即建立了 2 个什么都不做的连接? 是否以某种方式将初始 celery 连接限制为 0 或 1,或者让任务在 celery beat 连接上共享/运行?

最佳答案

虽然它实际上并没有限制连接,但另一个用户发现禁用连接池实际上减少了连接数: https://stackoverflow.com/a/23563018/1867779

BROKER_POOL_LIMIT = 0

Redis 和 Mongo 后端有自己的连接限制参数。

AMQP 后端没有这样的设置。

鉴于此,我不确定 BROKER_POOL_LIMIT 的用途,但我真的很想看看 CELERY_AMQP_MAX_CONNECTIONS

这是一个相关的、未回答的问题:How can I minimise connections with django-celery when using CloudAMQP through dotcloud?

关于python - Celery Cloudamqp 为每个任务创建新连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23249850/

相关文章:

python - Tesseract/PYOCR 将 'Z' 检测为 '2'

python - 使用脆皮表单将属性添加到表单字段

python - celery 长时间不活动后意外关闭

python - 在 Excel 工作表中查找填充内容的范围

python - 亚马逊 s3 的 boto 加密 key

javascript - Django 的 JSONP 响应

python - django celery get() 用于获取结果表单任务

django - 在Django-Celery中停止/清除定期任务

python - 可以在没有**任何**默认环境的情况下安装 Anaconda 吗?

python - to_python() 永远不会被调用(即使在 __metaclass__ = models.SubfieldBase 的情况下)