Re: Question regarding Queue object

2008-04-29 Thread Terry
On Apr 29, 5:30 pm, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > Terry <[EMAIL PROTECTED]> wrote: > > On Apr 28, 5:30 pm, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > > > David <[EMAIL PROTECTED]> wrote: > > > > Another idea would be to have multiple queues, one per thread or per > > > > message

Re: Question regarding Queue object

2008-04-29 Thread Terry
On Apr 29, 4:32 pm, [EMAIL PROTECTED] wrote: > On 27 Apr, 12:27, Terry <[EMAIL PROTECTED]> wrote: > > > > > Hello! > > > I'm trying to implement a message queue among threads using Queue. The > > message queue has two operations: > > PutMsg(id, msg) # this is simple, just combine the id and msg as

Re: Question regarding Queue object

2008-04-29 Thread Terry
On Apr 29, 3:01 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Sun, 27 Apr 2008 03:27:59 -0700 (PDT), Terry <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > I'm trying to implement a message queue among threads using Queue. The > > message queue has two operations: >

Re: Question regarding Queue object

2008-04-29 Thread Nick Craig-Wood
Terry <[EMAIL PROTECTED]> wrote: > On Apr 28, 5:30 pm, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > > David <[EMAIL PROTECTED]> wrote: > > > Another idea would be to have multiple queues, one per thread or per > > > message type "group". The producer thread pushes into the appropriate > > > que

Re: Question regarding Queue object

2008-04-29 Thread bockman
On 27 Apr, 12:27, Terry <[EMAIL PROTECTED]> wrote: > Hello! > > I'm trying to implement a message queue among threads using Queue. The > message queue has two operations: > PutMsg(id, msg) #  this is simple, just combine the id and msg as one > and put it into the Queue. > WaitMsg(ids, msg) # this

Re: Question regarding Queue object

2008-04-28 Thread Terry
On Apr 28, 10:48 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I've never used it myself but you may find candygram > interesting;http://candygram.sourceforge.net, which AFAIK implements > Erlang-style > message queues in Python. Thank you. I will look at candygram and stackless. I believ

Re: Question regarding Queue object

2008-04-28 Thread Terry
On Apr 28, 5:30 pm, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > David <[EMAIL PROTECTED]> wrote: > > 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)

Re: Question regarding Queue object

2008-04-28 Thread [EMAIL PROTECTED]
I've never used it myself but you may find candygram interesting; http://candygram.sourceforge.net, which AFAIK implements Erlang-style message queues in Python. -- http://mail.python.org/mailman/listinfo/python-list

Re: Question regarding Queue object

2008-04-28 Thread Nick Craig-Wood
David <[EMAIL PROTECTED]> wrote: > 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 i

Re: Question regarding Queue object

2008-04-27 Thread David
(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,

Re: Question regarding Queue object

2008-04-27 Thread David
> WaitMsg will get only msg with certain ids, but this is not possible > in Queue object, because Queue provides no method to peek into the > message queue and fetch only matched item. > > Now I'm using an ugly solution, fetch all the messages and put the not > used ones back to the queue. But

Re: Question regarding Queue object

2008-04-27 Thread Terry
On Apr 27, 6:27 pm, Terry <[EMAIL PROTECTED]> wrote: > Hello! > > I'm trying to implement a message queue among threads using Queue. The > message queue has two operations: > PutMsg(id, msg) # this is simple, just combine the id and msg as one > and put it into the Queue. > WaitMsg(ids, msg) # thi

Question regarding Queue object

2008-04-27 Thread Terry
Hello! I'm trying to implement a message queue among threads using Queue. The message queue has two operations: PutMsg(id, msg) # this is simple, just combine the id and msg as one and put it into the Queue. WaitMsg(ids, msg) # this is the hard part WaitMsg will get only msg with certain ids, bu