[Stackless] Hard switching and pickling

Hervé Coatanhay herve.coatanhay at gmail.com
Mon Nov 23 09:08:15 CET 2009


Hi,

After reading this thread
http://www.stackless.com/pipermail/stackless/2009-September/004271.html, I
tried to enable hard switching for stackless samples. I encountered the
following error with "*Pickling and unpickling simple tasklets*" example:

Traceback (most recent call last):
  File "/home/hcy/tmp/stackless_test.py", line 32, in <module>
    schedule()
RuntimeError: cannot execute invalid frame with 'eval_frame_value': frame
had a C state that can't be restored.

--

Here the code I used:

from stackless import run, schedule, tasklet, enable_softswitch
import pickle

enable_softswitch(False)

def aCallable(name):
    print "  aCallable<%s>: Before schedule()" % (name,)
    schedule()
    print "  aCallable<%s>: After schedule()" % (name,)

tasks = []
for name in "ABCDE":
    tasks.append(tasklet(aCallable)(name))

print "Schedule 1:"
schedule()

print
print "Pickling..."
pickledTasks = pickle.dumps(tasks)

print
print "Schedule 2:"
schedule()

unpickledTasks = pickle.loads(pickledTasks)
for task in unpickledTasks:
    task.insert()
print
print "Schedule Unpickled Tasks:"
schedule()

--

Is there a design incompatibility between "hard switching" and pickle ?

Herve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.stackless.com/pipermail/stackless/attachments/20091123/18e0eb6b/attachment.htm>


More information about the Stackless mailing list