python - 为什么每次celery+rabbitmq都会生成一个新队列?

标签 python celery

abmp.py:

from celery import Celery 
app = Celery('abmp', backend='amqp://guest@localhost',broker='amqp://guest@localhost' ) 

@app.task(bind=True) 
def add(self, a, b): 
    return a + b 

执行测试.py

from abmp import add 

add.apply_async( 
args=(5,7), 
queue='push_tasks', 
exchange='push_tasks', 
routing_key='push_tasks' 
) 

执行 celery

celery -A abmp worker -E -Q push_tasks -l info 

执行execute_test.py

python2.7 execute_test.py。

最后到rabbitmq后台查看,发现每次执行execute_test.py都会生成一个new队列,而不是把任务扔进push_tasks队列。

最佳答案

您正在使用 AMQP 作为结果后端。 Celery 将每个任务的结果存储为新队列,以任务 ID 命名。使用更适合的后端(例如 Redis)以避免向新队列发送垃圾邮件。

关于python - 为什么每次celery+rabbitmq都会生成一个新队列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43843156/

相关文章:

python - celery 服务器错误: "cannot mix new setting names with old setting names" while running the server

python - Celery:将任务结果存储在 MySQL 还是 Redis 中更好?

python - SqlAlchemy + Celery 与 Scoped Session 错误

Python 将 args 转换为 kwargs

python - 获取一个参数并运行基于该参数的函数

python - API前端架构

django - Elastic Beanstalk 中的 celery worker 错误(使用 django 和 SQS)[ImportError : The curl client requires the pycurl library.]

python - 如何将 io.StringIO() 与 csv 模块一起使用?

python - 使用 Tensorflow BERT 模型保存并进行推理

python - 将列表转换为数据框/调整一行循环