[Stackless] How to Schedule Re: Stackless Digest, Vol 27, Issue 13

Andrew Francis andrewfr_ice at yahoo.com
Wed Apr 26 18:20:49 CEST 2006

Hello Yi:

>I'm a newbie of stackless. I think the idea of
>stackless is great, but i found tasklets is 
>difficult to use in real world, maybe that's just
>because my thinking has been tied 
>to native threads :).

I am getting the swing of stackless. My two main
problems are deadlock and working with IO. I work
mostly with networking. I found that stackless is
highly effective with asynchronous IO. My strategy was
to write a controller(read scheduler) between "worker"
tasklets and the asynchronous IO routines. The
controller controls tasklets through channels.

>for example:
>      How to deal with UI and worker threads? when i
>call raw_input in 
>a console ui, everything get blocked.
>      how if i want to schedule one tasklet
>especially ,for example: 
>one of the tasklets keep running until it call
>stackless.schedule() itself , 
>but others can only run 100 instructions before they
>are suspended.

I do little work with UIs. So I may be talking out of
my hat. However most UIs have an event loop or an idle
function. I suspect a part of the solution is altering
the event loop to call stackless.schedule() as much as
possible if there is no IO activity. In turn, many UIs
have callbacks. Use the callbacks to communicate via
channels to some controller (read scheduler) that will
wake up your tasklets and have them do useful things.

As for raw_input. I suspect there is a way to use
asynchronous IO for this too.


Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

Stackless mailing list
Stackless at stackless.com

More information about the Stackless mailing list