[Stackless] tasklet time out

Richard Tew richard.m.tew at gmail.com
Wed Feb 29 08:34:06 CET 2012

On Wed, Feb 29, 2012 at 8:00 PM, piyush singhai
<singhai.piyush at gmail.com> wrote:
> Some of my tasklets are blocked because of which whole system is blocked.
> There is a option of timeout in run method but it is not time it is
> depending on number of instruction, how Can i specify the time.

It is impossible to know what your problem is from what you have said
above.  There is no timeout for the scheduler, if your tasklets are
blocking the scheduler and preventing other tasklets from running,
then you need to take a different approach.

The recommended approach is to pump the scheduler:
1) When a tasklet needs to block, do it in an asynchronous manner.
Post the asynchronous operation and block the tasklet on a channel
until the callback comes to awaken it from the channel back into the
2) Your main loop will continuously run the scheduler.  Most of the
time, it will have no tasklets to run because they will be out of the
scheduler blocked on channels waiting for IO to complete.

Here's a simple implementation of this approach:

Note that using asynchronous IO is something you need to take care of yourself.


More information about the Stackless mailing list