This is a feature request, it may however be an oversimplification of the problem. It is related to jezdez/hirefire#9. It is also possible the feature request should live more in celery than in kombu, though the machinery for such a celery feature would likely need to live here.
It would be really nice to have a defined api to get the current number of queued tasks for a given queue from a Channel object. At present, this can be done with transport backends which subclass from the virtual backend by use of the _size() method. However the two standard AMQP backends (py-amqp and librabbitmq do not define this method. I have been able to use queue_declare('queue_name', passive=True) on these backends and then access the message_count paramater, however these throw inconsistent exceptions in the case of the queue not existing (a different exception, both called ChannelError).
The api for queue_declare() is consistent across all backends, however I'm worried that it is doing more work than is strictly necessary here for some cases, in particular it looks up the number of active workers for a given queue as well as the length of the queue which seems superfluous.
If there exists an appropriate API for doing this, please do point me in the correct direction!
+1
Any progress on this?
+1
contributions are welcome
Most helpful comment
+1