[Stackless] Proposed modification WRT threading and scheduling

Jeff Senn senn at maya.com
Wed Jan 9 21:14:07 CET 2008

I think I'm with Richard on this one.  In fact I might say "fix the  
rather than "disable this behavior". :-)

Since you have no idea that any other threads have anything to do with
stackless (as in Richard's example) -- there is no reason for  
stackless.run() to
act differently when there is 1 thread versus >1 threads.

If .run() is going to return when there are no tasklets to run, then  
it should
ALWAYS do that.  And I do believe that returning is the "correct"  
decision because it leaves
the higher-level scheduling up to the implementor.  (You could, for  
instance as Arnar implies,
wrap .run() in a loop with time.sleep())

On an only-vaguely-related subject: it seems to me there is still some  
bug (resulting in crash)
that we never really found trying to *generally* support tasklets  
blocking/waking each other
across thread boundaries.  I, for instance, am going to some trouble  
to only do this
in particular "small" (well-characterized) ways.  Is anyone doing this  
in a large
enough scale to believe it is well tested?


On Jan 9, 2008, at 2:31 PM, Richard Tew wrote:

> On Jan 9, 2008 11:02 PM, Arnar Birgisson <arnarbi at gmail.com> wrote:
>> On Jan 9, 2008 8:25 AM, Richard Tew <richard.m.tew at gmail.com> wrote:
>>> I'd like to make a change to Stackless to optionally disable this
>>> behaviour, perhaps an option which can be set on the stackless  
>>> module,
>>> or a parameter to the 'stackless.run' function.
>> What do you mean by "disable this behaviour"? Would you make the
>> scheduler with no runnable tasklets busy-loop to poll for tasklets?  
>> If
>> so, the parameter you mention could be an integer, saying how many
>> milliseconds to sleep between polls, with the default value of 0
>> giving you the current blocking behaviour.
> As I understand it, this would make no difference.  The tasklets would
> have to be awakened by channel activity on the other threads.  This
> will already cause the main thread to awaken.
>> Or perhaps you have something different in mind?
> Yes.  I would just have the scheduler exit when there are no runnable
> tasklets left within it, regardless of the existence of other Python
> threads.  Any parameter or setting would be boolean.  By default False
> indicating that it should block for the other threads and True that it
> should retrieve the main tasklet and exit the scheduler.
> Richard.
> _______________________________________________
> Stackless mailing list
> Stackless at stackless.com
> http://www.stackless.com/mailman/listinfo/stackless

More information about the Stackless mailing list