celery 获取任务数
我正在使用 python celery+rabbitmq。我找不到一种方法来获取某个队列中的任务计数。 像这样的事情:
celery.queue('myqueue').count()
是否可以从某个队列中获取任务计数?
一种解决方案是从我的 python scrpit: 运行外部命令
"rabbitmqctl list_queues -p my_vhost"
并解析结果,这是一个好方法吗?
I am using python celery+rabbitmq. I can't find a way to get task count in some queue.
Some thing like this:
celery.queue('myqueue').count()
Is it posible to get tasks count from certaint queue?
One solution is to run external command from my python scrpit:
"rabbitmqctl list_queues -p my_vhost"
and parse results, is it good way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为使用rabbitmqctl命令不是一个好的解决方案,特别是在我的ubuntu服务器上,rabbitmqctl只能以root权限执行。
通过使用 pika 对象,我找到了可行的解决方案:
我没有找到有关使用 pika 检查 AMQP 队列的文档,因此我不知道解决方案的正确性。
I suppose that using rabbitmqctl command is not good solution, especially on my ubuntu server, where rabbitmqctl can be executed only with root privileges.
By playing with pika objects I found working solution:
I did not find documentation about inspecting the AMQP queue with pika, so I do not know about solution's correctness.