[Stackless] tasklet time out
Kristján Valur Jónsson
kristjan at ccpgames.com
Thu Mar 1 12:05:04 CET 2012
This has come up over here. We have been thining, for example, that tasklets should be able themselves to break out of "run", withough the currently hacky way of stackless.main.run()
Also, some sort of "break" callback which can be called regularly to see if we ought to break, rather than rely on this weird "instruction count" thingie.
In fact, with some slight modifications to stackless, it ought to be possible to write your own scheduler in a simple way. (The problem is that tasklet.run() leaves the caller runnable. Something like tasklet.run(remove=true) would be helpful as an atomic switching operation, allowing one to write one's own scheduler.)
I wrote something like this once, can post the source if anyone is interested.
> -----Original Message-----
> From: stackless-bounces at stackless.com [mailto:stackless-
> bounces at stackless.com] On Behalf Of Richard Tew
> Sent: 29. febrúar 2012 19:21
> To: The Stackless Python Mailing List
> Subject: Re: [Stackless] tasklet time out
> On Wed, Feb 29, 2012 at 11:06 PM, piyush singhai
> <singhai.piyush at gmail.com> wrote:
> > Now suppose one of the tasklet stuck in while true loop or infinite
> > loop because of the code bug you can say. Then no other tasklet will
> > get the turn to execute. I want to avoid this scenario. I am trying
> > to do using
> > stackless.run(timeout) but this timeout is number of instruction.
> You will have to make do with the instruction count timeout. There is no
> support for actual time-based timeouts.
> In my experience the instruction count timeout has been perfectly fine for
> this purpose. When you are pumping the scheduler, the theory is that
> tasklets spend most of their time outside of the scheduler blocked on
> channels. So the scheduler is expected to never block for very long, time-
> wise or instruction count-wise. Just decide on a low enough instruction
> count and you should be fine, a bit of experimentation should determine a
> suitable value.
> In practice, I've never seen our infinite loop detection kick in. I know it
> definitely works, but infinite loops never happen in practice.
> Stackless mailing list
> Stackless at stackless.com
More information about the Stackless