Howto wait for multiple queues (Queue.py)?

Skip Montanaro skip at pobox.com
Wed Nov 20 12:33:52 EST 2002


    Andreas> ... I want to be able to block the consumer thread until input
    Andreas> within one (or more) queues is available.

How about you maintain a single Queue which holds the other Queues?  When a
Queue goes empty it gets removed from the main Queue.  When something is
put() into it, it's added to the main Queue if it's not already there.  Your
consumers then wait on the main Queue.

Seems simple enough to subclass Queue and tweak its get and put methods.

Perhaps this was one of the alternatives you described but I didn't
understand.

-- 
Skip Montanaro - skip at pobox.com
http://www.mojam.com/
http://www.musi-cal.com/




More information about the Python-list mailing list