[Stackless] switching improvements
Kristján Valur Jónsson
kristjan at ccpgames.com
Thu Nov 29 12:27:08 CET 2012
Ok, take a look at https://bitbucket.org/krisvale/stacklessswitching
From: Christian Tismer [mailto:tismer at stackless.com]
Sent: 29. nóvember 2012 01:25
To: The Stackless Python Mailing List
Cc: Kristján Valur Jónsson
Subject: Re: [Stackless] switching improvements
how about checking it into a branch firt, let us try and check that
intensively, and after enough confidence merge it in?
That's the way that works best for me with Mercurial/Git.
If you don't like to put a branch into python.org, you also can do a clone
on bitbucket easily and let us use that for review.
cheers - chris
On 28.11.12 16:11, Kristján Valur Jónsson wrote:
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.
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?
Stackless mailing list
Stackless at stackless.com<mailto:Stackless at stackless.com>
Christian Tismer :^) <mailto:tismer at stackless.com><mailto:tismer at stackless.com>
Software Consulting : Have a break! Take a ride on Python's
Karl-Liebknecht-Str. 121 : *Starship* http://starship.python.net/
14482 Potsdam : PGP key -> http://pgp.uni-mainz.de
phone +49 173 24 18 776 fax +49 (30) 700143-0023
PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04
whom do you want to sponsor today? http://www.stackless.com/
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Stackless