Search code examples
pythonpython-3.xmultithreadingdata-structures

SimpleQueue vs Queue in Python - what is the advantage of using SimpleQueue?


The queue — A synchronized queue class simply states that

there are fewer functions allowed with SimpleQueue.

I need very basic queue functionality for a multithreading application, would it help in any way to use SimpleQueue?


Solution

  • queue.SimpleQueue handles more than threadsafe concurrency. It handles reentrancy - it is safe to call queue.SimpleQueue.put in precarious situations where it might be interrupting other work in the same thread. For example, you can safely call it from __del__ methods, weakref callbacks, or signal module signal handlers.

    If you need that, use queue.SimpleQueue.