[Stackless] stackless context managers
Kristján Valur Jónsson
kristjan at ccpgames.com
Thu Sep 5 08:48:43 CEST 2013
I think this is a better spot to discuss this topic than the checkin comments in Anselm's repo:
So, Anselm said:
Sorry for the delayed answer, here is the use case.
I tried to write a context manager that changes the execution host of the body. In __enter__ I pickle the tasklet and transfer the pickle to another process and unpickle it there. Then the tasklet executes until it calls __exit__. In exit I pickle it again and transfer it back to the original process.
This is really interesting. How did it pan out? Also, How does it work on the originating site? A context manager does not (currently) allow the body code to be skipped, which I presume is what must happen on the "source" side. (although, this here patch<http://bugs.python.org/issue18677> would allow that)
I'm very much a fan of context managers these days. I just added stackless.atomic(), a built-in to provide performance for this ubiquitous thing.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Stackless