Queue.Queue-like class without the busy-wait
Paul Rubin
http
Fri Mar 25 05:54:30 EST 2005
Antoon Pardon <apardon at forel.vub.ac.be> 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 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.
You could open a socket to your own loopback port and then select on
it, or something like that. The select call takes a timeout parameter.
> 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.
A signal handler in the main thread could release a lock that the
thread is waiting on.
More information about the Python-list
mailing list