(re-cc-ing the list) On Sun, Apr 27, 2008 at 4:40 PM, Terry Yin <[EMAIL PROTECTED]> wrote: > Defaultdict is not an option because there will be a lot of message IDs (and > increasing). I will implement LookAheadQueue class by overriding the Queue > class. > > Thanks for your kind advice. > > BTW, I have been in old-fashion telecommunication R&D for years, where > messages and state machines are heavily used in software development. And > this makes me automatically resort to messages between task-specific > processes/threads when designing any software, even in python. I'm wondering > if this is the right choice, or it's already not a modern way of design. >
There are a lot of ways you could go about it, those 2 were the first that came to mind. Another idea would be to have multiple queues, one per thread or per message type "group". The producer thread pushes into the appropriate queues (through an intelligent PutMsg function), and the consumer threads pull from the queues they're interested in and ignore the others. If your apps are heavily threaded you might take a look at Stackless Python: http://www.stackless.com/ David. -- http://mail.python.org/mailman/listinfo/python-list