Queue.Queue-like class without the busy-wait
apardon at forel.vub.ac.be
Fri Mar 25 11:44:24 CET 2005
Op 2005-03-25, Paul Rubin schreef <http>:
> Antoon Pardon <apardon at forel.vub.ac.be> 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
> I meant a semaphore to synchronize the queue when adding or removing
Last I looked there was a lock used for that.
The loop is only for when you cant remove or add an element immediatly
and there is a timeout.
> Timeout would be handled with sigalarm or select.
How is select going to help? IMO you can't put a Queue in a select call.
And it is doubtfull if working with sigalarm will do the trick.
First of all is the problem the signal module in python is very limited.
IIRC all signals are routed to the main thread. So breaking a lock
by having the thread signaled is impossible in python.
You may provide your own signal module, but that may not be enough.
The last time I experimented with a pthreads in C, locks didn't
break by signalling the thread. That might be a bug, but I wouldn't
know since I'm not familiar with the pthread specifications.
More information about the Python-list