[Stackless] Example and doubts about the functioning of stackless

Jeff Senn senn at maya.com
Thu Aug 24 20:58:22 CEST 2006


On Aug 24, 2006, at 10:49 AM, Carlos Eduardo de Paula wrote:

> Hi all,
>
> I´m still playing with stackless until I get a project to use it. I  
> created a small app to perform a task and display a progressbar,  
> each on its own tasklet.
>
> My questions are:
>
> - When I run the task in the doStuff alone(without the progressbar)  
> the task is completed in about 1.06 seconds in my machine, and when  
> I run it with the PB, it takes 2.17 seconds.

Well... it is not surprising that your progress bar takes *some* CPU;  
and since
your main tasklet isn't really doing much, the tasklet switching time  
will
look relatively large in comparison.

> - When the task is finished it sends a signal to the PB so it  
> stops, but the app stays running (i think its the  
> ManageSleepingTasklets tasklet, how can i make it exit and finish?

Yes. You need a smarter mechanism for ManageSleeping (perhaps it  
should exit when there are no tasklets
sleeping and only get started when the sleeping count goes from 0->1).

> - When the task is finished and the app is still running(see  
> above), my CPU stays at 100%. What can I do to make my app not use  
> all CPU?

Yep.  ManageSleeping is using all your CPU (if you look carefully it  
should be obvious why...
the .schedule() call winds up just re-scheduling itself in the case  
when it is the only tasklet).

I believe someone posted a better ManageSleeping at some point...

Idea: if ManageSleeping is the only running tasklet and there is no  
tasklet ready to run again,
simply call time.sleep(endTime-time.time())

-Jas




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



More information about the Stackless mailing list