I have a multiprocessing.Manager
object that contains a multiprocessing.Queue
to manage all of the work that I want a group of processes to do. I would like to get the number of elements left in this queue and was wondering how to do this?
Python's inbuilt len()
function does not work.
If the queue you are talking about is multiprocessing.Queue
, try to use qsize()
method for multiprocessing.Queue
objects, but be careful:
qsize()
Return the approximate size of the queue. Because of multithreading/multiprocessing semantics, this number is not reliable.
Note that this may raise NotImplementedError on Unix platforms like Mac OS X where sem_getvalue() is not implemented.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With