Hi Bin:

________________________________
 From: Bin Huang <[email protected]>
To: Andrew Francis <[email protected]> 
Cc: "[email protected]" <[email protected]> 
Sent: Friday, June 14, 2013 4:29 PM
Subject: More questions on stackless.run()
 

>As you suggested, I found thinking of stackless.run() being in an infinite 
>loop was helpful. So I >went on to test stackless.run() in a few different 
>scenarios. This time, I got confused by different >outputs in different 
>scenarios.


Typically you execute stackless.run() once. A common structure for a Stackless 
Python
programme is:

your-programme-goes-here
stackless.run()

I ought to look at how stackless.run() is implemented but think of 
stackless.run conceptually
as a pump that schedules tasklets as long as there are runnable tasklets.  
Again, conceptually
stackless.run() is akin to:

while stackless.getruncount() > 1:
      stackless.schedule()

As long as there is more than one tasklet (the main), the next tasklet in the 
runnable queue will be 
scheduled.

...

>Third, if I don't even call stackless.run(), the stackless runtime is still 
>able to schedule some tasklets >to run (e.g., code #2). Why is this?

Good question. I don't have a good answer (without looking at the code) but a 
number of operations
will engage the scheduler and get the ball rolling. The scheduler in 
non-preemptive mode is a passive entity: it has to be called to do things.

Cheers,
Andrew
_______________________________________________
Stackless mailing list
[email protected]
http://www.stackless.com/mailman/listinfo/stackless

Reply via email to