Howto wait for multiple queues (Queue.py)?

Alex Martelli aleax at aleax.it
Wed Nov 20 12:16:31 EST 2002


Andreas Ames wrote:

> as I prefer to use queues for interthread communication, I need

Queues are GREAT for interthread communication, BUT:

> something like a 'mainloop' for my threads in the sense that every
> thread can have multiple input queues and I want to be able to block

...this doesn't follow -- just make all requests to a thread onto
a single Queue (tag the requests with 'kind' or whatever as needed)
and live happily.  A Queue instance *IS* implicitly, automatically
and intrinsically "synchronized" -- several threads can be reading
and/or writing to the same Queue instance and you're guaranteed that
they'll never interfere with each other.  That's just about the
whole POINT of the Queue class.


Alex




More information about the Python-list mailing list