[Stackless] Stackless uthread-ccp module usage

Richard Tew richard.m.tew at gmail.com
Sat Feb 24 16:43:05 CET 2007


On 2/23/07, Carlos Eduardo de Paula <cedepaula at yahoo.com.br> wrote:
> I found that the problem is around the Run() function in uthread module, it
> checks for yieldChannel.balance or len(sleepingTasklets) but none have
> tasklets on yet on startup, putting some debug into Run method, i checked
> that only after 1 loop the yieldChannel gets to -5 (quantity of tasklets I
> have).
>
> Am I doing something wrong or any correction should be made on Run method?

You are right.  A correction is needed.

It also needs to check the scheduler runcount.  It should be easy to
add this.  I am unable to check in a fixed version at this time, due
to limited internet connectivity.

I am at this time hesitant to promote the Run aspect of the uthread-ccp
module.  Instead I am leaning towards the two scheduling examples
I mailed about several days ago.  But I am also hesitant to suggest
they be used instead because on the other hand uthread.Run adds
simplicity even if it hides what is actually happening.

> One more thing... I didnt get the:
>
>         t = stackless.run(10000000)
>         if t is not None:
>             # Need better standard handling of this case.
>             # Could StackTrace I guess?
>             raise RuntimeError("Runaway tasklet", t.id)
>
> How do this watchdog works, what is the 100000000 in the run? Seconds? What
> do it waits till an exception is raised?

Not able to check to make sure, I believe it is virtual machine opcodes
executed.  The alternative scheduling method which uthread-ccp Run
does is oriented around keeping the scheduler empty. It is a bug if
you have a tasklet which runs too long, and that number is
generous (10000000). However raising an error is the lazy approach.

The safe approach is to print a traceback for that tasklet, then call:

  t.insert()

Then run the scheduler again immediately. The goal is to maintain
the cooperative model.  The reason for this is that that tasklet may
have been interrupted anywhere, and to run other tasklets in
the meantime would be preemptive and could have unexpected
results.

> Ps.Sorry if i´m a little dumb on this but its something i didnt got yet.

No problem.  I just hope I addressed what you mentioned sufficiently.

Cheers,
Richard.

_______________________________________________
Stackless mailing list
Stackless at stackless.com
http://www.stackless.com/mailman/listinfo/stackless



More information about the Stackless mailing list