Re: Queue.Queue() AttributeError exception

2010-05-13 Thread Carl Banks
On May 12, 11:50 pm, Dennis Lee Bieber wrote: > On Mon, 10 May 2010 10:40:51 +0800, "ÖÓ±þÓÂ" > declaimed the following in gmane.comp.python.general: > > > I have a multi-thread program work with Queue.Queue(), sometimes put > > request to the work queue,

Queue.Queue() AttributeError exception

2010-05-12 Thread 钟炳勇
I have a multi-thread program work with Queue.Queue(), sometimes put request to the work queue, but throw an exception as below traceback information, it will always throw the exception until restart program, cound please have any experience, your help will be greatly appreciated! File "

Re: Simple question about Queue.Queue and threads

2010-02-08 Thread Frank Millman
On Feb 8, 4:51 pm, Steven wrote: Queue objects have support for this signaling baked in with q.task_done and q.join. After the server process has put all tasks into the queue, it can join the queue itself, not the worker threads. q.join() This will block until all tasks have been gotten AND

Re: Simple question about Queue.Queue and threads

2010-02-08 Thread Steven
On Feb 5, 7:45 am, "Frank Millman" wrote: > Hi all > > Assume you have a server process running, a pool of worker threads to > perform tasks, and aQueue.Queue() to pass the tasks to the workers. > > In order to shut down the server cleanly, you want to ensure that the > workers have all finished t

Re: Simple question about Queue.Queue and threads

2010-02-05 Thread Frank Millman
On Feb 6, 7:59 am, "Gabriel Genellina" wrote: En Fri, 05 Feb 2010 09:45:30 -0300, Frank Millman escribió: [...] > However, the queue is not empty - it still has the final None in it. Yes - but who cares? :) That was my point. I didn't think I needed to care, but I wanted to be sure I w

Re: Simple question about Queue.Queue and threads

2010-02-05 Thread Gabriel Genellina
En Fri, 05 Feb 2010 09:45:30 -0300, Frank Millman escribió: Assume you have a server process running, a pool of worker threads to perform tasks, and a Queue.Queue() to pass the tasks to the workers. In order to shut down the server cleanly, you want to ensure that the workers have all

Simple question about Queue.Queue and threads

2010-02-05 Thread Frank Millman
Hi all Assume you have a server process running, a pool of worker threads to perform tasks, and a Queue.Queue() to pass the tasks to the workers. In order to shut down the server cleanly, you want to ensure that the workers have all finished their tasks. I like the technique of putting a

Re: Slow Queue.queue? (was: slow network)

2009-01-15 Thread Laszlo Nagy
I would try something like this inside _process_outgoing: while not self.stop_requested.isSet(): data_ok = False while not self.stop_requested.isSet(): if not self.outgoing.empty(): try:

Re: Slow Queue.queue? (was: slow network)

2009-01-15 Thread bieffe62
On 15 Gen, 10:22, Laszlo Nagy wrote: > > then the speed goes up to 64 messages/sec on windows and 500 > > messages/sec on Linux. > > Finally I could reach 1500 messages/sec without using the queue. If I > comment out one line (use the queue instead of direct write into socket) > then speed decreas

Re: Slow Queue.queue? (was: slow network)

2009-01-15 Thread Laszlo Nagy
then the speed goes up to 64 messages/sec on windows and 500 messages/sec on Linux. Finally I could reach 1500 messages/sec without using the queue. If I comment out one line (use the queue instead of direct write into socket) then speed decreases to 40-60 messages/sec. I don't understand wh

Slow Queue.queue? (was: slow network)

2009-01-15 Thread Laszlo Nagy
I had this test program originally that sent message over TCP/IP. Messages where buffered two a Queue.Queue instances, one for incoming and one for outgoing. #1. endpoint.send_message(msg) -> endpoint.outgoing.put(msg) #2. endpoint._process_outgoing() is a thread, that d

is Queue.Queue() serializable with cPickle?

2006-03-01 Thread john peter
i have the following custom extenstion of Queue.Queue() to save and load queue contents but I think there's a problem with it. Does anybody know qhether Queue.Queue() is pickle-able? if so, can I get sample code? If not, can anybody recommend a pickle-able Queue from another library t

Re: Queue.Queue()

2006-02-17 Thread Tim Peters
[john peter] > what happens behind the scenes when i create a Queue.Queue() without > specifying a maxsize? does a block of space gets allocated initially then > dynamically "expanded" as needed? Yes. > if so, what is the default size of the initial space? It'

Queue.Queue()

2006-02-17 Thread john peter
 what happens behind the scene when i create a Queue.Queue() without specifyinga maxsize?  does a block of space gets allocated initially then dynamically "expanded" as needed?  if so, what is the default size of the initial space? is italways better to specify a big enou

Queue.Queue()

2006-02-16 Thread john peter
 what happens behind the scenes when i create a Queue.Queue() without specifying a maxsize?  does a block of space gets allocated initially then dynamically "expanded" as needed?  if so, what is the default size of the initial space? is it always better to specify a big enou

Re: Queue.Queue-like class without the busy-wait

2005-04-04 Thread Antoon Pardon
Op 2005-04-02, Paul Rubin schreef : > Have you looked at this? A paper about adding asynchronous exceptions > to Python. > > http://www.cs.williams.edu/~freund/papers/02-lwl2.ps Looks interresting, but I doubt python will have it in the near future. I'm very pessimitic about python development in

Re: Queue.Queue-like class without the busy-wait

2005-04-04 Thread Nick Craig-Wood
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Thinking about cross-platform issues. I found this, from the venerable > Tim Peters to be enlightening for python's choice of design: > > "It's possible to build a better Queue implementation that runs only on > POSIX systems, or only on Windows s

Re: Queue.Queue-like class without the busy-wait

2005-04-03 Thread Nick Craig-Wood
Paul Rubin wrote: > Nick Craig-Wood <[EMAIL PROTECTED]> writes: > > I believe futex is the thing you want for a modern linux. Not > > very portable though. > > That's really cool, but I don't see how it can be a pure userspace > operation if the futex has a timeout. The kernel must need to k

Re: Queue.Queue-like class without the busy-wait

2005-04-01 Thread Paul Rubin
Nick Craig-Wood <[EMAIL PROTECTED]> writes: > I believe futex is the thing you want for a modern linux. Not > very portable though. That's really cool, but I don't see how it can be a pure userspace operation if the futex has a timeout. The kernel must need to keep track of the timeouts. Howeve

Re: Queue.Queue-like class without the busy-wait

2005-04-01 Thread Nick Craig-Wood
Paul Rubin wrote: > Antoon Pardon <[EMAIL PROTECTED]> writes: > > I'm not sure that this would be an acceptable approach. I did the man > > semop and it indicates this is part of system V IPC. This makes me > > fear that semaphores will use file descriptors or other resources > > that are only av

Re: Queue.Queue-like class without the busy-wait

2005-04-01 Thread Paul Rubin
Have you looked at this? A paper about adding asynchronous exceptions to Python. http://www.cs.williams.edu/~freund/papers/02-lwl2.ps -- http://mail.python.org/mailman/listinfo/python-list

Re: Queue.Queue-like class without the busy-wait

2005-04-01 Thread David Bolen
"Paul L. Du Bois" <[EMAIL PROTECTED]> writes: > Has anyone written a Queue.Queue replacement that avoids busy-waiting? > It doesn't matter if it uses os-specific APIs (eg > WaitForMultipleObjects). I did some googling around and haven't found > anyt

Re: Queue.Queue-like class without the busy-wait

2005-04-01 Thread Antoon Pardon
Op 2005-03-31, [EMAIL PROTECTED] schreef <[EMAIL PROTECTED]>: > Cool Code! > > One possible sticking point is that I think select only works on > network sockets on windows. This would make the code not crossplatforn. As far as I understand, what I did with pipes, can be done just as fine with ne

Re: Queue.Queue-like class without the busy-wait

2005-03-31 Thread pyguy2
Thinking about cross-platform issues. I found this, from the venerable Tim Peters to be enlightening for python's choice of design: "It's possible to build a better Queue implementation that runs only on POSIX systems, or only on Windows systems, or only on one of a dozen other less-popular target

Re: Queue.Queue-like class without the busy-wait

2005-03-31 Thread pyguy2
Cool Code! One possible sticking point is that I think select only works on network sockets on windows. This would make the code not crossplatforn. john -- http://mail.python.org/mailman/listinfo/python-list

Re: Queue.Queue-like class without the busy-wait

2005-03-30 Thread Paul Rubin
Antoon Pardon <[EMAIL PROTECTED]> writes: > I'm not sure that this would be an acceptable approach. I did the man > semop and it indicates this is part of system V IPC. This makes me > fear that semaphores will use file descriptors or other resources > that are only available in a limited amount. N

Re: Queue.Queue-like class without the busy-wait

2005-03-30 Thread Antoon Pardon
Op 2005-03-30, Paul Rubin schreef : >> > I think the best bet for the short term is handling it at the C level, >> > with sigalarm. Another way is to have chained sigalarm handlers in >> > the main thread. >> >> Possible, but I don't have the time to investigate that possibility now. > > Actuall

Re: Queue.Queue-like class without the busy-wait

2005-03-29 Thread Paul Rubin
Antoon Pardon <[EMAIL PROTECTED]> writes: > > There needs to be a way to send signals to threads, or raise > > asynchronous exceptions in them. There's been some discussion in > > sourceforge about that, but the issues involved are complex. > > Well I have raised this issue before and as far as I

Re: Queue.Queue-like class without the busy-wait

2005-03-29 Thread Antoon Pardon
Op 2005-03-29, Paul Rubin schreef : > Antoon Pardon <[EMAIL PROTECTED]> writes: >> I'm not going to call my solution simple, but it wastes very few >> cycles. if no thread is blocked on a lock, the select will just >> block until that changes. No need for some kind of polling loop. > > I think I un

Re: Queue.Queue-like class without the busy-wait

2005-03-29 Thread Paul Rubin
Antoon Pardon <[EMAIL PROTECTED]> writes: > I'm not going to call my solution simple, but it wastes very few > cycles. if no thread is blocked on a lock, the select will just > block until that changes. No need for some kind of polling loop. I think I understand. My original idea was to use a hea

Re: Queue.Queue-like class without the busy-wait

2005-03-29 Thread Antoon Pardon
Op 2005-03-29, Antoon Pardon schreef <[EMAIL PROTECTED]>: > Op 2005-03-29, Paul Rubin schreef : >> Antoon Pardon <[EMAIL PROTECTED]> writes: >>> Well have a look at what I have written over the weekend. It uses >>> a seperate thread with one pipe for a wakeup mechanisme. >> >> Thanks, I'll look at

Re: Queue.Queue-like class without the busy-wait

2005-03-29 Thread Antoon Pardon
Op 2005-03-29, Paul Rubin schreef : > Antoon Pardon <[EMAIL PROTECTED]> writes: >> Well have a look at what I have written over the weekend. It uses >> a seperate thread with one pipe for a wakeup mechanisme. > > Thanks, I'll look at it. Why don't you use usleep instead of a pipe? Because with th

Re: Queue.Queue-like class without the busy-wait

2005-03-29 Thread Paul Rubin
Antoon Pardon <[EMAIL PROTECTED]> writes: > Well have a look at what I have written over the weekend. It uses > a seperate thread with one pipe for a wakeup mechanisme. Thanks, I'll look at it. Why don't you use usleep instead of a pipe? I decided over the weekend that using a separate thread wit

Re: Queue.Queue-like class without the busy-wait

2005-03-29 Thread Antoon Pardon
Op 2005-03-25, Paul Rubin schreef : > Antoon Pardon <[EMAIL PROTECTED]> writes: >> Well maybe you could use an os.pipe as a timeout lock then. When the lock is >> instantiated you put one byte in it. Aquiring the lock is implemented by >> reading one byte, releasing the lock is implemented by writi

Re: Queue.Queue-like class without the busy-wait

2005-03-25 Thread Paul Rubin
Antoon Pardon <[EMAIL PROTECTED]> writes: > Well maybe you could use an os.pipe as a timeout lock then. When the lock is > instantiated you put one byte in it. Aquiring the lock is implemented by > reading one byte, releasing the lock is implemented by writing a byte. > Aquiring the lock with a tim

Re: Queue.Queue-like class without the busy-wait

2005-03-25 Thread Antoon Pardon
Op 2005-03-25, Paul Rubin schreef : > Antoon Pardon <[EMAIL PROTECTED]> writes: >> > I meant a semaphore to synchronize the queue when adding or removing >> > objects. >> >> Last I looked there was a lock used for that. > > OK, that amounts to the same thing. > >> The loop is only for when you c

Re: Queue.Queue-like class without the busy-wait

2005-03-25 Thread Paul Rubin
Antoon Pardon <[EMAIL PROTECTED]> writes: > > I meant a semaphore to synchronize the queue when adding or removing > > objects. > > Last I looked there was a lock used for that. OK, that amounts to the same thing. > The loop is only for when you cant remove or add an element immediatly > and th

Re: Queue.Queue-like class without the busy-wait

2005-03-25 Thread Antoon Pardon
Op 2005-03-25, Paul Rubin schreef : > Antoon Pardon <[EMAIL PROTECTED]> writes: >> > I've never checked this code but it wouldn't have occurred to me that >> > Queue uses any kind of timeout loop. Can't it work the obvious way >> > with a semaphore? >> >> And how is this semaphore going to be rel

Re: Queue.Queue-like class without the busy-wait

2005-03-25 Thread Paul Rubin
Antoon Pardon <[EMAIL PROTECTED]> writes: > > I've never checked this code but it wouldn't have occurred to me that > > Queue uses any kind of timeout loop. Can't it work the obvious way > > with a semaphore? > > And how is this semaphore going to be released if the timeout is > reached? I meant

Re: Queue.Queue-like class without the busy-wait

2005-03-25 Thread Antoon Pardon
intermediate >> cancel, as the loop that is used in Queue.Queue, so that was no >> gain. > > I've never checked this code but it wouldn't have occurred to me that > Queue uses any kind of timeout loop. Can't it work the obvious way > with a semaphore? And ho

Re: Queue.Queue-like class without the busy-wait

2005-03-25 Thread Paul Rubin
Antoon Pardon <[EMAIL PROTECTED]> writes: > I started once, using the Timer class in the Threading Module to > break the lock. However the Timer class uses the same kind of > sleep-polling loop, to delay the exection and allow an intermediate > cancel, as the loop that is used

Re: Queue.Queue-like class without the busy-wait

2005-03-25 Thread Antoon Pardon
Op 2005-03-24, Paul L. Du Bois schreef <[EMAIL PROTECTED]>: > Has anyone written a Queue.Queue replacement that avoids busy-waiting? > It doesn't matter if it uses os-specific APIs (eg > WaitForMultipleObjects). I did some googling around and haven't found > anyt

Re: Queue.Queue-like class without the busy-wait

2005-03-24 Thread Paul L. Du Bois
Peter Hansen wrote: > I don't believe the term "busy-wait" applies here. > [Explanation] Yes, well, you're right. I was thinking of calling it "slacker-waiting" but didn't want to come off too cute. p -- http://mail.python.org/mailman/listinfo/python-list

Re: Queue.Queue-like class without the busy-wait

2005-03-24 Thread Peter Hansen
Paul L. Du Bois wrote: Has anyone written a Queue.Queue replacement that avoids busy-waiting? It doesn't matter if it uses os-specific APIs (eg WaitForMultipleObjects). I did some googling around and haven't found anything so far. Because I know someone will ask: no, the busy-waiting h

Queue.Queue-like class without the busy-wait

2005-03-24 Thread Paul L. Du Bois
Has anyone written a Queue.Queue replacement that avoids busy-waiting? It doesn't matter if it uses os-specific APIs (eg WaitForMultipleObjects). I did some googling around and haven't found anything so far. Because I know someone will ask: no, the busy-waiting hasn't been a pr