芹菜临时排队 [英] Temporary queue made in Celery

查看:66
本文介绍了芹菜临时排队的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Celery与RabbitMQ结合使用。最近,我注意到正在建立大量的临时队列。

I am using Celery with RabbitMQ. Lately, I have noticed that a large number of temporary queues are getting made.

因此,我进行了实验,发现当任务失败时(即任务引发异常) ),然后会形成一个具有随机名称的临时队列(例如c76861943b0a4f3aaa6a99a6db06952c),并保留该队列。

So, I experimented and found that when a task fails (that is a tasks raises an Exception), then a temporary queue with a random name (like c76861943b0a4f3aaa6a99a6db06952c) is formed and the queue remains.

在Rabbitmqadmin中发现的临时队列的某些属性如下-

Some properties of the temporary queue as found in rabbitmqadmin are as follows -

auto_delete:True
消费者:0
持久性:False
消息:1
messages_ready:1

auto_delete : True consumers : 0 durable : False messages : 1 messages_ready : 1

每次执行任务时,都会创建一个这样的临时队列失败(即引发Exception)。如何避免这种情况?因为在我的生产环境中会形成大量这样的队列。

And one such temporary queue is made everytime a task fails (that is, raises an Exception). How to avoid this situation? Because in my production environment a large number of such queues get formed.

推荐答案

好吧,Philip就在那里。以下是我如何解决它的描述。它是celeryconfig.py中的配置。

Well, Philip is right there. The following is a description of how I solved it. It is a configuration in celeryconfig.py.

我仍然使用Philip所说的CELERY_BACKEND = amqp。但是除此之外,我现在使用的是CELERY_IGNORE_RESULT = True。此配置将确保不会为每个任务形成额外的队列。

I am still using CELERY_BACKEND = "amqp" as Philip had said. But in addition to that, I am now using CELERY_IGNORE_RESULT = True. This configuration will ensure that the extra queues are not formed for every task.

我已经在使用此配置,但是当任务失败时,仍会形成额外的队列。然后我注意到我正在使用另一个需要删除的配置,即CELERY_STORE_ERRORS_EVEN_IF_IGNORED = True。这样做的结果是它不存储所有任务的结果,而只存储错误(失败的任务),因此为失败的任务增加了一个队列。

I was already using this configuration but still when a task fails, the extra queue was formed. Then I noticed that I was using another configuration which needed to be removed which was CELERY_STORE_ERRORS_EVEN_IF_IGNORED = True. What this did that it did not store the results for all tasks but did only for errors (tasks which failed) and hence one extra queue for a task which failed.

这篇关于芹菜临时排队的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆