Re: Queue peek?

2010-03-08 Thread Aahz
In article 58f61382-ac79-46fb-8612-a3c9fde29...@c16g2000yqd.googlegroups.com, Veloz michaelve...@gmail.com wrote: The peek parts comes in when the user comes back later to see if their report has done. That is, in my page controller logic, I'd like to look through the complete queue and see if

Re: Queue peek?

2010-03-04 Thread Gregory Ewing
Floris Bruynooghe wrote: I was just wondering if other people ever missed the q.put_at_front_of_queue() method or if it is just me. Sounds like you don't want a queue, but a stack. Or maybe a double-ended queue. -- Greg -- http://mail.python.org/mailman/listinfo/python-list

Re: Queue peek?

2010-03-03 Thread Veloz
On Mar 3, 1:14 am, Gregory Ewing greg.ew...@canterbury.ac.nz wrote: MRAB wrote: I suppose it depends on the complexity of the data structure. A dict's methods are threadsafe, for example, but if you have a data structure where access leads to multiple method calls then collectively they

Re: Queue peek?

2010-03-03 Thread Steve Holden
Veloz wrote: On Mar 3, 1:14 am, Gregory Ewing greg.ew...@canterbury.ac.nz wrote: MRAB wrote: I suppose it depends on the complexity of the data structure. A dict's methods are threadsafe, for example, but if you have a data structure where access leads to multiple method calls then

Re: Queue peek?

2010-03-03 Thread mk
Veloz wrote: Unless I missed where you guys were going, I think we got off the main point. The main question at hand was this: what's the best way (heck, any way) to implement a sort of peek whereby a number of processes can write results to some common object and some other process can peek

Re: Queue peek?

2010-03-03 Thread Floris Bruynooghe
On Mar 2, 6:18 pm, Raymond Hettinger pyt...@rcn.com wrote: On Mar 2, 8:29 am, Veloz michaelve...@gmail.com wrote: Hi all I'm looking for a queue that I can use with multiprocessing, which has a peek method. I've seen some discussion about queue.peek but don't see anything in the docs

Queue peek?

2010-03-02 Thread Veloz
Hi all I'm looking for a queue that I can use with multiprocessing, which has a peek method. I've seen some discussion about queue.peek but don't see anything in the docs about it. Does python have a queue class with peek semantics? Michael --

Re: Queue peek?

2010-03-02 Thread Raymond Hettinger
On Mar 2, 8:29 am, Veloz michaelve...@gmail.com wrote: Hi all I'm looking for a queue that I can use with multiprocessing, which has a peek method. I've seen some discussion about queue.peek but don't see anything in the docs about it. Does python have a queue class with peek semantics?

Re: Queue peek?

2010-03-02 Thread Veloz
On Mar 2, 1:18 pm, Raymond Hettinger pyt...@rcn.com wrote: On Mar 2, 8:29 am, Veloz michaelve...@gmail.com wrote: Hi all I'm looking for a queue that I can use with multiprocessing, which has a peek method. I've seen some discussion about queue.peek but don't see anything in the docs

Re: Queue peek?

2010-03-02 Thread MRAB
Veloz wrote: On Mar 2, 1:18 pm, Raymond Hettinger pyt...@rcn.com wrote: On Mar 2, 8:29 am, Veloz michaelve...@gmail.com wrote: Hi all I'm looking for a queue that I can use with multiprocessing, which has a peek method. I've seen some discussion about queue.peek but don't see anything in the

Re: Queue peek?

2010-03-02 Thread Martin P. Hellwig
On 03/02/10 19:44, MRAB wrote: cut information, such as when it was completed, the status (OK or failed), etc. You might want to wrap it in a class with locks (mutexes) to ensure it's threadsafe. What actually happens if multiple threads at the same time, write to a shared dictionary (Not using

Re: Queue peek?

2010-03-02 Thread Daniel Stutzbach
On Tue, Mar 2, 2010 at 1:58 PM, Martin P. Hellwig martin.hell...@dcuktec.org wrote: What actually happens if multiple threads at the same time, write to a shared dictionary (Not using the same key)? All of Python's built-in types are thread safe. Both updates will happen. -- Daniel

Re: Queue peek?

2010-03-02 Thread mk
Daniel Stutzbach wrote: On Tue, Mar 2, 2010 at 1:58 PM, Martin P. Hellwig martin.hell...@dcuktec.org mailto:martin.hell...@dcuktec.org wrote: What actually happens if multiple threads at the same time, write to a shared dictionary (Not using the same key)? All of Python's built-in

Re: Queue peek?

2010-03-02 Thread John Krukoff
On Tue, 2010-03-02 at 22:54 +0100, mk wrote: snip No need to use synchro primitives like locks? I know that it may work, but that strikes me as somehow wrong... I'm used to using things like Lock().acquire() and Lock().release() when accessing shared data structures, whatever they are.

Re: Queue peek?

2010-03-02 Thread MRAB
John Krukoff wrote: On Tue, 2010-03-02 at 22:54 +0100, mk wrote: snip No need to use synchro primitives like locks? I know that it may work, but that strikes me as somehow wrong... I'm used to using things like Lock().acquire() and Lock().release() when accessing shared data structures,

Re: Queue peek?

2010-03-02 Thread Gregory Ewing
MRAB wrote: I suppose it depends on the complexity of the data structure. A dict's methods are threadsafe, for example, but if you have a data structure where access leads to multiple method calls then collectively they need a lock. It also depends on the nature of the objects being used as