<html>
<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:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","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";}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";
        mso-fareast-language:EN-GB;}
span.EmailStyle20
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle21
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle22
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@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-GB" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Ok, this makes sense.  What you are seeing is the failure to pickle inaccessible functions inside the wingware debugger.  It is the debug callback frame that
 is failing, and this frame contains local variables, including “has_key” that point to anonymous functions.  Anonymous functions cannot (currently) be pickled, since all functions are (currently) pikled by name.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I suppose we _<i>could</i>_ add function recreation (i.e. pickle the code objects) in such cases….<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">But anyway, the reason you are failing is because you are running inside the debugger
</span><span style="font-size:11.0pt;font-family:Wingdings;color:#1F497D">J</span><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">K<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> stackless-bounces@stackless.com [mailto:stackless-bounces@stackless.com]
<b>On Behalf Of </b>Kristján Valur Jónsson<br>
<b>Sent:</b> 11. október 2013 14:48<br>
<b>To:</b> The Stackless Python Mailing List<br>
<b>Subject:</b> Re: [Stackless] Fwd: deepcopying (pickling) channels<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Ok, running this in the wingware debugger, I see this is happening because it is trying to pickle the debugging frame!</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I need to investigate more what Is happening, but functions cannot be pickled if they are not accessible by name, and some of the debugging code internal functions
 might be anonymous.</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Stackless can pickle frames and functions, as long as those functions are pickleable by name, IIRC.</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">K</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">
<a href="mailto:stackless-bounces@stackless.com">stackless-bounces@stackless.com</a> [<a href="mailto:stackless-bounces@stackless.com">mailto:stackless-bounces@stackless.com</a>]
<b>On Behalf Of </b>Kristján Valur Jónsson<br>
<b>Sent:</b> 11. október 2013 11:21<br>
<b>To:</b> The Stackless Python Mailing List<br>
<b>Subject:</b> Re: [Stackless] Fwd: deepcopying (pickling) channels</span><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">“I run this with the default settings in wing IDE. If i run it in IDLE, there is no exception.”<o:p></o:p></p>
<p class="MsoNormal">That sounds like the problem.<o:p></o:p></p>
<p class="MsoNormal">Boy, do I hate how hard it is to debug pickling problems.  for “pickle” we really should have a flag that prints out the hierarchy as it is pickling.<o:p></o:p></p>
<p class="MsoNormal">Maybe someone has already done that?<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">Anyway, I’ll install Wingware and see if I can reproduce it there.  I’m sure wingware is messing with pickling in some unexpected way.<o:p></o:p></p>
<p class="MsoNormal">(I’m unfamiliar with wingware, btw.   If you feel up to it, try putting debugging code inside pickle.py to dump out what it is doing, that might be faster.  I would guess that it is doing something with  the copy_reg module and this is
 messing with our function pickling.<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">K<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">
<a href="mailto:stackless-bounces@stackless.com">stackless-bounces@stackless.com</a> [<a href="mailto:stackless-bounces@stackless.com">mailto:stackless-bounces@stackless.com</a>]
<b>On Behalf Of </b>lars van Gemerden<br>
<b>Sent:</b> 10. október 2013 15:24<br>
<b>To:</b> The Stackless Python Mailing List<br>
<b>Subject:</b> Re: [Stackless] Fwd: deepcopying (pickling) channels</span><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"> <o:p></o:p></p>
<div>
<p class="MsoNormal">the callstack is:<o:p></o:p></p>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal">pickle.PicklingError: Can't pickle <type 'function'>: it's not found as __builtin__.function<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "d:\Documents\Code\python\floware\toolshed\tests\stackless_test.py", line 34, in <module><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  print pickle.dumps(t) #ERROR<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 1411, in dumps<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  Pickler(file, protocol).dump(obj)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 231, in dump<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  self.save(obj)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 338, in save<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  self.save_reduce(obj=obj, *rv)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 426, in save_reduce<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  save(state)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 293, in save<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  f(self, obj) # Call unbound method with explicit self<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 661, in save_dict<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  self._batch_setitems(obj.iteritems())<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 675, in _batch_setitems<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  save(v)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 338, in save<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  self.save_reduce(obj=obj, *rv)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 426, in save_reduce<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  save(state)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 293, in save<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  f(self, obj) # Call unbound method with explicit self<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 569, in save_tuple<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  save(element)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 293, in save<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  f(self, obj) # Call unbound method with explicit self<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 607, in save_list<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  self._batch_appends(iter(obj))<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 622, in _batch_appends<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  save(x)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 338, in save<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  self.save_reduce(obj=obj, *rv)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 426, in save_reduce<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  save(state)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 293, in save<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  f(self, obj) # Call unbound method with explicit self<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 569, in save_tuple<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  save(element)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 293, in save<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  f(self, obj) # Call unbound method with explicit self<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 607, in save_list<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  self._batch_appends(iter(obj))<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 622, in _batch_appends<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  save(x)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 338, in save<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  self.save_reduce(obj=obj, *rv)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 426, in save_reduce<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  save(state)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 293, in save<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  f(self, obj) # Call unbound method with explicit self<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 569, in save_tuple<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  save(element)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 293, in save<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  f(self, obj) # Call unbound method with explicit self<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 661, in save_dict<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  self._batch_setitems(obj.iteritems())<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 675, in _batch_setitems<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  save(v)                                                                               <== THIS LINE<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 293, in save<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  f(self, obj) # Call unbound method with explicit self<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 802, in save_function<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  return self.save_reduce(obj=obj, *rv)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 426, in save_reduce<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  save(state)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 293, in save<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  f(self, obj) # Call unbound method with explicit self<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 569, in save_tuple<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  save(element)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 293, in save<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  f(self, obj) # Call unbound method with explicit self<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 661, in save_dict<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  self._batch_setitems(obj.iteritems())<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 675, in _batch_setitems<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  save(v)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 338, in save<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  self.save_reduce(obj=obj, *rv)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 426, in save_reduce<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  save(state)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 293, in save<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  f(self, obj) # Call unbound method with explicit self<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 661, in save_dict<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  self._batch_setitems(obj.iteritems())<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 675, in _batch_setitems<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  save(v)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 293, in save<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  f(self, obj) # Call unbound method with explicit self<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">File "C:\Python27\lib\pickle.py", line 760, in save_global<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  (obj, module, name))<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Probably not that usefull without values ... in THIS LINE above,  v is module C:\python27\lib\new.pyc.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">I don't think there is a framework in place that would influence this script, the imports (pickle, stackless) are unaltered.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">I run this with the default settings in wing IDE. If i run it in IDLE, there is no exception.<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"> <o:p></o:p></p>
<div>
<p class="MsoNormal">On Thu, Oct 10, 2013 at 3:22 PM, Kristján Valur Jónsson <<a href="mailto:kristjan@ccpgames.com" target="_blank">kristjan@ccpgames.com</a>> wrote:<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">The error is weird.  It seems to be trying to pickle the “function” type.  It shouldn’t try doing
 that.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Now, I know that pickling channels with tasklets on them works.  This is what stackless does.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I tried saving your code into a module and just running it from the command line.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I wonder if there is some copy_reg magic that is interfering with the code.  How are you running
 it?  Is this when running the code as a module, or when typing it in from the console?</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Are you trying this in a stand-alone environment or in some application framework?</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Finally, can I see the full traceback for the pickle exception.  If you are using pickle (and not
 cPickle) a traceback can help us find out why it is failing.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">K</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">
<a href="mailto:stackless-bounces@stackless.com" target="_blank">stackless-bounces@stackless.com</a> [mailto:<a href="mailto:stackless-bounces@stackless.com" target="_blank">stackless-bounces@stackless.com</a>]
<b>On Behalf Of </b>lars van Gemerden<br>
<b>Sent:</b> 9. október 2013 12:48</span><o:p></o:p></p>
<div>
<p class="MsoNormal"><br>
<b>To:</b> The Stackless Python Mailing List<o:p></o:p></p>
</div>
<p class="MsoNormal"><b>Subject:</b> Re: [Stackless] Fwd: deepcopying (pickling) channels<o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Hi Kristjan,<o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">the version i am using is: python 2.7.5 Stackless 3.1b3 (from binary).<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">I think the stackless mailsystem was a little off, i tried with pickle.dumps (see mail history below), with the error: <span style="font-size:10.0pt;font-family:"Arial","sans-serif"">pickle.PicklingError:
 Can't pickle <type 'function'>: it's not found as __builtin__.function.</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">"</span><span style="font-size:11.5pt;font-family:"Calibri","sans-serif";color:#1F497D">stackless.run() returns when
 there are no <i>runnable</i> tasklets ...", ok, clear, thanks.</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.5pt;font-family:"Calibri","sans-serif";color:#1F497D">Cheers, Lars</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:12.0pt"> <o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">On Wed, Oct 9, 2013 at 2:36 PM, lars van Gemerden <<a href="mailto:lars@rational-it.com" target="_blank">lars@rational-it.com</a>> wrote:<o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">I am reasonably familiar with pickle (e.g. i know you cant pickle most functions), but this is pretty stackless specific: why can i pickle an empty channel, but not a sending/receiving
 channel?<o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Cheers, Lars<o:p></o:p></p>
</div>
</div>
<div>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:12.0pt"> <o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">On Mon, Oct 7, 2013 at 7:50 PM, Anselm Kruis <<a href="mailto:a.kruis@science-computing.de" target="_blank">a.kruis@science-computing.de</a>> wrote:<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Hi Lars,<br>
<br>
you are observing well known deficiencies of the pickle/cPickle implementation of Python. Perhaps sPickle (<a href="http://pypi.python.org/pypi/sPickle" target="_blank">http://pypi.python.org/pypi/sPickle</a>) can pickle the channels.<br>
<br>
Regards<br>
  Anselm<br>
<br>
<br>
Am <a href="tel:06.10.2013%2008" target="_blank">06.10.2013 08</a>:58, schrieb lars van Gemerden:<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:12.0pt">maybe double but i got a mail bounce ..<br>
<br>
---------- Forwarded message ----------<br>
From: lars van Gemerden <<a href="mailto:lars@rational-it.com" target="_blank">lars@rational-it.com</a>><br>
Date: Thu, Oct 3, 2013 at 6:15 PM<br>
Subject: Re: [Stackless] deepcopying (pickling) channels<br>
To: The Stackless Python Mailing List <<a href="mailto:stackless@stackless.com" target="_blank">stackless@stackless.com</a>><br>
<br>
<br>
actually both give an error. The only thing different is the error message.<br>
with pickle the code would be:<br>
<br>
---------------------------------------------------------------------------<br>
import stackless, pickle<br>
<br>
class Test(object):<br>
     def __init__(self):<br>
         self.channel = stackless.channel()<br>
<br>
     def run(self):<br>
         stackless.tasklet(self.sender)()<br>
         stackless.tasklet(self.receiver)()<br>
         stackless.run()<br>
<br>
     def sender(self):<br>
         counter = 0<br>
         while counter < 10:<br>
             self.channel.send(counter)<br>
             counter += 1<br>
<br>
     def receiver(self):<br>
         counter = 0<br>
         while counter < 12:<br>
             counter = self.channel.receive()<br>
             print counter,<br>
         print "done"<br>
<br>
if __name__ == "__main__":<br>
<br>
     t = Test()<br>
     t.run()<br>
     t.channel = None<br>
     s = pickle.dumps(t) #OK<br>
<br>
     t = Test()<br>
     t.run()<br>
     s = pickle.dumps(t) #ERROR<br>
-----------------------------------------------------------------------------<br>
and the error:<br>
<br>
pickle.PicklingError: Can't pickle <type 'function'>: it's not found as<br>
__builtin__.function<br>
<br>
otherwise the error behavior is the same as decribed above.<br>
<br>
Cheers, Lars<br>
<br>
(as far as i have read and tested a bit, deepcopy allows more to be copied<br>
then pickle, but cPickle is faster, so i have my own deepcopy:<br>
<br>
def deepcopy(obj):<br>
     try:<br>
         return cPickle.loads(cPickle.dumps(obj, -1))<br>
     except PicklingError:<br>
         return copy.deepcopy(obj)<br>
)<br>
<br>
<br>
On Thu, Oct 3, 2013 at 5:19 AM, Richard Tew <<a href="mailto:richard.m.tew@gmail.com" target="_blank">richard.m.tew@gmail.com</a>> wrote:<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:12.0pt">I'm a little confused.  Are you pickling the tasklets, or copying<br>
them?  These are different things to Python.<br>
<br>
As far as I know using copy or deepcopy has never been supported for<br>
tasklets and therefore channels.<br>
<br>
Pickling however, is another matter.<br>
<br>
Cheers,<br>
Richard.<br>
<br>
_______________________________________________<br>
Stackless mailing list<br>
<a href="mailto:Stackless@stackless.com" target="_blank">Stackless@stackless.com</a><br>
<a href="http://www.stackless.com/mailman/listinfo/stackless" target="_blank">http://www.stackless.com/mailman/listinfo/stackless</a><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><br>
<br>
<br>
<br>
<br>
maybe double but i got a mail bounce ..<br>
<br>
---------- Forwarded message ----------<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">From: *lars van Gemerden* <<a href="mailto:lars@rational-it.com" target="_blank">lars@rational-it.com</a><br>
<mailto:<a href="mailto:lars@rational-it.com" target="_blank">lars@rational-it.com</a>>><br>
Date: Thu, Oct 3, 2013 at 6:15 PM<br>
Subject: Re: [Stackless] deepcopying (pickling) channels<br>
To: The Stackless Python Mailing List <<a href="mailto:stackless@stackless.com" target="_blank">stackless@stackless.com</a><o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><mailto:<a href="mailto:stackless@stackless.com" target="_blank">stackless@stackless.com</a>>><br>
<br>
<br>
actually both give an error. The only thing different is the error<br>
message. with pickle the code would be:<br>
<br>
---------------------------------------------------------------------------<br>
import stackless, pickle<br>
<br>
class Test(object):<br>
     def __init__(self):<br>
         self.channel = stackless.channel()<br>
     def run(self):<br>
         stackless.tasklet(self.sender)()<br>
         stackless.tasklet(self.receiver)()<br>
         stackless.run()<br>
     def sender(self):<br>
         counter = 0<br>
         while counter < 10:<br>
             self.channel.send(counter)<br>
             counter += 1<br>
     def receiver(self):<br>
         counter = 0<br>
         while counter < 12:<br>
             counter = self.channel.receive()<br>
             print counter,<br>
         print "done"<br>
if __name__ == "__main__":<br>
     t = Test()<br>
     t.run()<br>
     t.channel = None<br>
     s = pickle.dumps(t) #OK<br>
     t = Test()<br>
     t.run()<br>
     s = pickle.dumps(t) #ERROR<br>
-----------------------------------------------------------------------------<br>
and the error:<br>
<br>
pickle.PicklingError: Can't pickle <type 'function'>: it's not found as<br>
__builtin__.function<br>
<br>
otherwise the error behavior is the same as decribed above.<br>
<br>
Cheers, Lars<br>
<br>
(as far as i have read and tested a bit, deepcopy allows more to be<br>
copied then pickle, but cPickle is faster, so i have my own deepcopy:<br>
<br>
def deepcopy(obj):<br>
     try:<br>
         return cPickle.loads(cPickle.dumps(obj, -1))<br>
     except PicklingError:<br>
         return copy.deepcopy(obj)<br>
)<br>
<br>
<br>
On Thu, Oct 3, 2013 at 5:19 AM, Richard Tew <<a href="mailto:richard.m.tew@gmail.com" target="_blank">richard.m.tew@gmail.com</a><o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><mailto:<a href="mailto:richard.m.tew@gmail.com" target="_blank">richard.m.tew@gmail.com</a>>> wrote:<br>
<br>
    I'm a little confused.  Are you pickling the tasklets, or copying<br>
    them?  These are different things to Python.<br>
<br>
    As far as I know using copy or deepcopy has never been supported for<br>
    tasklets and therefore channels.<br>
<br>
    Pickling however, is another matter.<br>
<br>
    Cheers,<br>
    Richard.<br>
<br>
    _______________________________________________<br>
    Stackless mailing list<o:p></o:p></p>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">   
<a href="mailto:Stackless@stackless.com" target="_blank">Stackless@stackless.com</a> <mailto:<a href="mailto:Stackless@stackless.com" target="_blank">Stackless@stackless.com</a>><o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><br>
    <a href="http://www.stackless.com/mailman/listinfo/stackless" target="_blank">
http://www.stackless.com/mailman/listinfo/stackless</a><br>
<br>
<br>
<br>
<br>
--<br>
====================================<br>
Lars van Gemerden<o:p></o:p></p>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><a href="mailto:lars@rational-it.com" target="_blank">lars@rational-it.com</a> <mailto:<a href="mailto:lars@rational-it.com" target="_blank">lars@rational-it.com</a>><br>
<a href="tel:%2B31%206%2026%2088%2055%2039" target="_blank">+31 6 26 88 55 39</a> <<a href="tel:%2B31%206%2026%2088%2055%2039" target="_blank">tel:%2B31%206%2026%2088%2055%2039</a>><o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><br>
====================================<br>
<br>
<br>
<br>
--<br>
====================================<br>
Lars van Gemerden<o:p></o:p></p>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><a href="mailto:lars@rational-it.com" target="_blank">lars@rational-it.com</a> <mailto:<a href="mailto:lars@rational-it.com" target="_blank">lars@rational-it.com</a>><o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:12.0pt"><br>
<a href="tel:%2B31%206%2026%2088%2055%2039" target="_blank">+31 6 26 88 55 39</a><br>
====================================<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:12.0pt">_______________________________________________<br>
Stackless mailing list<br>
<a href="mailto:Stackless@stackless.com" target="_blank">Stackless@stackless.com</a><br>
<a href="http://www.stackless.com/mailman/listinfo/stackless" target="_blank">http://www.stackless.com/mailman/listinfo/stackless</a><o:p></o:p></p>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="color:#888888"><br>
-- <br>
 Dipl. Phys. Anselm Kruis                       science + computing ag<br>
 Senior Solution Architect                      Ingolstädter Str. 22<br>
 email <a href="mailto:A.Kruis@science-computing.de" target="_blank">A.Kruis@science-computing.de</a>             80807 München, Germany<br>
 phone <a href="tel:%2B49%2089%20356386%20874" target="_blank">+49 89 356386 874</a>  fax 737              
<a href="http://www.science-computing.de" target="_blank">www.science-computing.de</a><br>
-- <br>
Vorstandsvorsitzender/Chairman of the board of management:<br>
Gerd-Lothar Leonhart<br>
Vorstand/Board of Management:<br>
Dr. Bernd Finkbeiner, Michael Heinrichs, Dr. Arno Steitz, Dr. Ingrid Zech<br>
Vorsitzender des Aufsichtsrats/<br>
Chairman of the Supervisory Board:<br>
Philippe Miltin<br>
Sitz/Registered Office: Tuebingen<br>
Registergericht/Registration Court: Stuttgart<br>
Registernummer/Commercial Register No.: HRB 382196</span><o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><br>
<br>
<br>
_______________________________________________<br>
Stackless mailing list<br>
<a href="mailto:Stackless@stackless.com" target="_blank">Stackless@stackless.com</a><br>
<a href="http://www.stackless.com/mailman/listinfo/stackless" target="_blank">http://www.stackless.com/mailman/listinfo/stackless</a><o:p></o:p></p>
</div>
</div>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><br>
<br clear="all">
<o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">--
<br>
====================================<br>
Lars van Gemerden<br>
<a href="mailto:lars@rational-it.com" target="_blank">lars@rational-it.com</a><br>
<a href="tel:%2B31%206%2026%2088%2055%2039" target="_blank">+31 6 26 88 55 39</a><br>
==================================== <o:p></o:p></p>
</div>
</div>
</div>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><br>
<br clear="all">
<o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">--
<br>
====================================<br>
Lars van Gemerden<br>
<a href="mailto:lars@rational-it.com" target="_blank">lars@rational-it.com</a><br>
<a href="tel:%2B31%206%2026%2088%2055%2039" target="_blank">+31 6 26 88 55 39</a><br>
==================================== <o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><br>
_______________________________________________<br>
Stackless mailing list<br>
<a href="mailto:Stackless@stackless.com">Stackless@stackless.com</a><br>
<a href="http://www.stackless.com/mailman/listinfo/stackless" target="_blank">http://www.stackless.com/mailman/listinfo/stackless</a><o:p></o:p></p>
</div>
<p class="MsoNormal"><br>
<br clear="all">
<o:p></o:p></p>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<p class="MsoNormal">-- <br>
====================================<br>
Lars van Gemerden<br>
<a href="mailto:lars@rational-it.com">lars@rational-it.com</a><br>
+31 6 26 88 55 39<br>
==================================== <o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>