Queue.Queue-like class without the busy-wait
Paul Rubin
http
Tue Mar 29 06:36:24 EST 2005
Antoon Pardon <apardon at forel.vub.ac.be> 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 with usleep is
the simplest thing to do in pure Python. If you want to use sigalarm,
that should be put in the low level C sigalarm handler so it gets
taken care separately from the Python interpreter does anything with
the signal. Locks should also be low level primitives.
I don't know how this stuff maps onto PyPy but I sincerely hope the
looping stuff goes away. Having a series of processing steps
connected by queues is a perfectly good way to organize a program, but
if there's even just 20 steps, then waiting for all those 50 msec
wakeups adds a whole second to the processing latency if the system
has been sleeping for a while. The latency really only needs to be in
the microseconds on a system with efficient enough threading.
More information about the Python-list
mailing list