I need a queue which multiple threads can put stuff into, and multiple threads may read from.
Python has at least two queue classes, Queue.Queue and collections.dequ
(seems I don't have reputation to comment...) You need to be careful which methods of the deque you use from different threads.
deque.get() appears to be threadsafe, but I have found that doing
for item in a_deque:
process(item)
can fail if another thread is adding items at the same time. I got an RuntimeException that complained "deque mutated during iteration".
Check collectionsmodule.c to see which operations are affected by this