Re: Not fully understanding the role of Queue.task_done()

2008-09-07 Thread alex23
Fredrik Lundh <[EMAIL PROTECTED]> wrote: > (btw, I've always thought that Python was all about making it easy to > express the solution to a given problem in code, not to let you write > programs without using your brain.  when did that change?) The day Google App Engine was opened up to developer

Re: Not fully understanding the role of Queue.task_done()

2008-09-07 Thread Fredrik Lundh
Aahz wrote: why are you using a queue for this case, btw? why not just use a plain list L = [] lock = threading.Lock() and add stuff using append in the monitor threads with lock: L.append(item) Because using a queue requires less thinking. given that the whole reason

Re: Not fully understanding the role of Queue.task_done()

2008-09-07 Thread Aahz
In article <[EMAIL PROTECTED]>, Fredrik Lundh <[EMAIL PROTECTED]> wrote: >Martin DeMello wrote: >> >> In the interests of not hammering the db unnecessarily, I'm >> considering the following >> 1. A series of independent "monitor" threads that collect information >> over TCP from the cluster of ma

Re: Not fully understanding the role of Queue.task_done()

2008-09-04 Thread Martin DeMello
On Sep 4, 1:51 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Martin DeMello wrote: > > I'm writing a cluster monitor, that collects information from a set of > > machines and logs it to a database > > > In the interests of not hammering the db unnecessarily, I'm > > considering the following > > 1

Re: Not fully understanding the role of Queue.task_done()

2008-09-04 Thread Fredrik Lundh
Martin DeMello wrote: I'm writing a cluster monitor, that collects information from a set of machines and logs it to a database In the interests of not hammering the db unnecessarily, I'm considering the following 1. A series of independent "monitor" threads that collect information over TCP fr

Re: Not fully understanding the role of Queue.task_done()

2008-09-04 Thread Martin DeMello
On Sep 4, 1:04 pm, castironpi <[EMAIL PROTECTED]> wrote: > > Random access isn't supported by the defined interface.  You can make > it more convenient, though. Thanks. I wasn't looking for random access, just wondering what the cleanest way to implement items = Queue.get_all() was. Your code shou

Re: Not fully understanding the role of Queue.task_done()

2008-09-04 Thread castironpi
On Sep 4, 2:51 pm, Martin DeMello <[EMAIL PROTECTED]> wrote: > On Sep 4, 12:41 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > > > "task_done" just decrements a counter (incremented by "put").  when the > > counter reaches zero, the "join" call is unblocked. > > Thanks! Is there any standard python

Re: Not fully understanding the role of Queue.task_done()

2008-09-04 Thread Martin DeMello
On Sep 4, 12:41 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > "task_done" just decrements a counter (incremented by "put").  when the > counter reaches zero, the "join" call is unblocked. Thanks! Is there any standard python idiom to empty a queue into a list? Or do I just call get() repeatedly

Re: Not fully understanding the role of Queue.task_done()

2008-09-04 Thread Fredrik Lundh
Martin DeMello wrote: Reading up on python's built in Queue class, though, it seems oriented towards "job queues", with a two-step dequeue operation (get() and task_done()). I'm worried that this would make it too heavyweight for my application. Is ther documentation somewhere on what exactly ta

Not fully understanding the role of Queue.task_done()

2008-09-04 Thread Martin DeMello
I'm writing a cluster monitor, that collects information from a set of machines and logs it to a database In the interests of not hammering the db unnecessarily, I'm considering the following 1. A series of independent "monitor" threads that collect information over TCP from the cluster of machine