[Stackless] Eliminating Busy Waits and Unnecssary Sleeps
ef at alum.mit.edu
Wed Aug 8 21:40:47 CEST 2007
On 8/8/07, seun.osewa at gmail.com <seun.osewa at gmail.com> wrote:
> Hmmm, this reminds me of stacklessfile.py and stacklesssoocket.py.
It serves a similar purpose, but the implementation is different. I
suspect mine has better performance under most loads, but I don't have
any data to back that up.
> Can you explain how yours works and show us some sample code?
It's basically a standard poll()-based event-loop, except that
stackless gives us a nice way of transparently transferring control
between the tasklets using channels. The code is really it's own best
description. If you're not familiar with poll() it won't make sense,
so I'd recommend learning about that first.
As for usage, it's pretty trivial. Use io.Socket just like you would
use socket.socket, and io.sleep just like you would use time.sleep.
Whenever an operation needs to block, the current tasklet will
actually register with the IO tasklet and then block on a channel,
allowing other tasks to run.
Stackless mailing list
Stackless at stackless.com
More information about the Stackless