<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
code
        {mso-style-priority:99;
        font-family:"Courier New";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.apple-converted-space
        {mso-style-name:apple-converted-space;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Hi, <o:p></o:p></p>
<p class="MsoNormal">I think this is a better spot to discuss this topic than the checkin comments in Anselm’s repo:<o:p></o:p></p>
<p class="MsoNormal"><a href="https://bitbucket.org/akruis/fg2python/commits/852868afc498e800e4091e83aa818bf5d7b35939#comment-406276">https://bitbucket.org/akruis/fg2python/commits/852868afc498e800e4091e83aa818bf5d7b35939#comment-406276</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">So, Anselm said:<o:p></o:p></p>
<p style="mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:0cm;margin-left:36.0pt;margin-bottom:.0001pt;line-height:15.0pt;background:white">
<span style="font-size:10.5pt;font-family:"Arial","sans-serif";color:#333333">Sorry for the delayed answer, here is the use case.<o:p></o:p></span></p>
<p style="mso-margin-top-alt:7.5pt;margin-right:0cm;margin-bottom:7.5pt;margin-left:36.0pt;line-height:15.0pt;background:white;word-wrap: break-word;orphans: auto;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:10.5pt;font-family:"Arial","sans-serif";color:#333333">I tried to write a context manager that changes the execution host of the body. In<span class="apple-converted-space"> </span></span><code><span style="font-size:9.0pt;color:#333333;border:solid #CCCCCC 1.0pt;padding:1.0pt;background:whitesmoke">__enter__</span></code><span class="apple-converted-space"><span style="font-size:10.5pt;font-family:"Arial","sans-serif";color:#333333"> </span></span><span style="font-size:10.5pt;font-family:"Arial","sans-serif";color:#333333">I
 pickle the tasklet and transfer the pickle to another process and unpickle it there. Then the tasklet executes until it calls<span class="apple-converted-space"> </span></span><code><span style="font-size:9.0pt;color:#333333;border:solid #CCCCCC 1.0pt;padding:1.0pt;background:whitesmoke">__exit__</span></code><span style="font-size:10.5pt;font-family:"Arial","sans-serif";color:#333333">.
 In exit I pickle it again and transfer it back to the original process.<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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<a href="http://bugs.python.org/issue18677">,
 this here patch</a> would allow that)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>