And in fact, I am working on exactly this kind of functionality, soon to be 
checked into stackless as part of the proposed "stacklesslib" package.  Stay 
tuned.
K

From: [email protected] [mailto:[email protected]] 
On Behalf Of Christian Tismer
Sent: 17. apríl 2010 17:39
To: The Stackless Python Mailing List
Cc: Andrew Tutt
Subject: Re: [Stackless] Interruptable wait aka Receive with Timeout

On 4/17/10 4:34 PM, Andrew Tutt wrote:
This idiom has probably already been contributed, but the following code 
implements "interruptable wait" which could also be thought of the opposite 
way, as implementing receive() with a timeout.

Also, I've taken the liberty on the following code of actually using a small 
sleep call between schedules. This, I have found massively decreases CPU load 
while altering my performance very little. Your results may vary, but as you 
may already be aware, there is no way that I can think of that one can 
implement sleep that is not busy in stackless, so this is the next best thing. 
You could easily extend it to make it tweak the length of the time.sleep based 
on load of course.
Without looking at the code now, who says that a non-busy sleep
cannot be implemented? Make a timer class with a singleton
instance that keeps track of all sleepers. As soon as all
but one tasklets are sleeping, the last tasklet can compute
the time until one will wake up, and really sleep for that period.

ciao - chris


--

Christian Tismer             :^)   
<mailto:[email protected]><mailto:[email protected]>

tismerysoft GmbH             :     Have a break! Take a ride on Python's

Johannes-Niemeyer-Weg 9A     :    *Starship* http://starship.python.net/

14109 Berlin                 :     PGP key -> http://wwwkeys.pgp.net/

work +49 30 802 86 56  mobile +49 173 24 18 776  fax +49 30 80 90 57 05

PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04

      whom do you want to sponsor today?   http://www.stackless.com/
_______________________________________________
Stackless mailing list
[email protected]
http://www.stackless.com/mailman/listinfo/stackless

Reply via email to