gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-05 05:20:58 25 4
gpt4 key购买 nike

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com