faster-fifo
faster-fifo copied to clipboard
Question
Is size method thread(multi-process ) safe?
And, will faster fifo queue faster be than mp queue in case many publishers single consumer?
Is it possible to have several such queues? Would be there some deadlocks?
Hi Nikita!
Is size method thread(multi-process ) safe?
qsize() is safe to call across threads and processes but it only gives you an approximation of the number of messages. I recommend using it only for diagnostic/logging purposes and not to make decisions. It's semantics is similar to standard multiprocessing.Queue https://docs.python.org/3/library/multiprocessing.html#multiprocessing.Queue.qsize
This means that you have to be careful with code like this:
if q.qsize() > 0:
# another process can change the queue size here
do something important ...
And, will faster fifo queue faster be than mp queue in case many publishers single consumer?
In this scenario you should get the most gains especially if you use get_many()
Is it possible to have several such queues? Would be there some deadlocks?
I have 100+ queues in some of my applications. So yes, you can have many queues per process, per thread and across processes/threads.