Howto wait for multiple queues (Queue.py)?

Bengt Richter bokr at oz.net
Thu Nov 21 11:46:53 EST 2002


On 20 Nov 2002 12:50:07 +0100, Andreas Ames <andreas.ames at tenovis.com> wrote:

>Hi,
>
>as I prefer to use queues for interthread communication, I need
>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
>the consumer thread until input within one (or more) queues is
>available.  This mechanism should be somewhat comparable to 'select()'
>or 'MsgWaitForMultipleObjects()' (on w32).
>
[...<ideas long on possible hows, short on whys>...]

ISTM there are a lot of questions that need to be answered before anyone can
get a grasp of what your problem really is, without making a lot of assumptions.

Step back from the implementation issues a moment. You have multiple threads. Ok.
They are to communicate. Ok. But what is the possible graph of their communications?
Pipeline? Acyclic? Static? etc. Do produced messages have types that sometimes or always
require direction to a[?] certain consumer[s?]? Are there ordered subsequences of messages
that must arrive in original order at single consumers, even though several consumers might be
able to process them? Or, e.g., could a thread simply requeue an item it can't process?

I could go on, but I imagine you get the point: the specs are not all visible from here ;-)

Regards,
Bengt Richter



More information about the Python-list mailing list