Op 2005-03-29, Paul Rubin schreef <http>:
> 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 the pipe the "sleep" can be indeterminate.

The select make the thread sleep until either of the folowing
happens.

  1) A timeout, which means one of the locks has to be broken

  2) A byte was received. This means a lock was tried to be
     acquired and inserted in the heap, so the timeout may
     need to be recalculated. (acquiring a lock, sends a
     byte over the pipe)

> I decided over the weekend that using a separate thread with usleep is
> the simplest thing to do in pure Python.

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.

-- 
Antoon Pardon
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to