[Stackless] Error for the pickle of a module in a package + patch

Christian Tismer tismer at stackless.com
Sat Nov 10 15:48:46 CET 2007


Christian Tismer wrote:
> Attached a working pickling demo and a non-working one.
> It barfs when running the second time, argument tasklet.pickle

pasted the failing program as text, since I see it show up
badly in the list archive.

------------------------------ snip -------------------------
import pickle, sys
import stackless

ch = stackless.channel()

def recurs(depth):
     def sub(level):
         print 'enter level %s%d' % (level*'  ', level)
         if level >= depth:
             ch.send('hi')
         if level < depth:
             sub(level+1)
         print 'leave level %s%d' % (level*'  ', level)
     sub(1)

def demo(depth):
     t = stackless.tasklet(recurs)(depth)
     print ch.receive()
     pickle.dump(t, file('tasklet.pickle', 'wb'))

if __name__ == '__main__':
     if len(sys.argv) > 1:
         t = pickle.load(file(sys.argv[1], 'rb'))
         t.insert()
     else:
         t = stackless.tasklet(demo)(14)
     stackless.run()

# remark: think of fixing cells etc. on the sprint
------------------------------ d!us -------------------------

-- 
Christian Tismer             :^)   <mailto:tismer at stackless.com>
tismerysoft GmbH             :     Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9A     :    *Starship* http://starship.python.net/
14109 Berlin                 :     PGP key -> http://wwwkeys.pgp.net/
work +49 30 802 86 56  mobile +49 173 24 18 776  fax +49 30 80 90 57 05
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
       whom do you want to sponsor today?   http://www.stackless.com/




More information about the Stackless mailing list