Hello All.
I was recently prompted to add a flag to stackless, a way to block all tasklet 
switching.
This springs from the way that we are embedding stackless python in an game 
engine (UnReal) which sometimes makes callbacks into python.  Sometimes, this 
code will do nasty stuff that results in tasks switching, causing havoc with 
the control flow of the game engine.
To simplify this, I added a per-thread flag, switch_trap, which can be 
controlled in a similar way to block_trap.  If the logic causes a switch to be 
attempted, this should be trappable and the code should be easily fixable, or 
we can otherwise deal with it.

Anyway, doing this, adding it to slp_schedule_task(), and so on, uncovered a 
subtle flaw in stackless:
It turns out that slp_schedule_task() had no way of differentiating whether an 
exception result from this call came as a result of a failure to switch, or an 
exception being sent to the tasklet when it wakes up again.

So, I have changed the interface to be able to do this properly.  There are 
other reasons why switching can fail, including memory allocation failures and 
so on, so this seems like a necessary change.  I also fixed code both in 
stacklesseval.c and taskletmodule and channelobject to be able to cope with 
switch failure like this.

Now:
How does this sound to you?  The change is somewhat large and I would hesitate 
to simply check it in without some sort of review or otherwise approval.  Any 
suggestions?

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

Reply via email to