def testSendSequence(self): # Send sequence when pickled was not handled. It uses # a custom cframe execute function which was not recognised # by the pickling. # # Traceback (most recent call last): # File ".\test_pickle.py", line 283, in testSendSequence # pickle.dumps(t1) # ValueError: frame exec function at 1e00bf40 is not registered! def sender(chan): l = [1, 2, 3, 4] chan.send_sequence(l) def receiver(chan): length = 4 while length: v = chan.receive() length -= 1 c = stackless.channel() t1 = stackless.tasklet(sender)(c) t2 = stackless.tasklet(receiver)(c) t1.run() pickle.dumps(t1)
def reduce_current(): """This function has exactly one local variable (func), one cellvar (result2) and one freevar (result)""" result2 = result # create the cell variable def func(current): result2.append(stackless._wrap.frame.__reduce__(current.frame)) stackless.tasklet().bind(func, (stackless.current,)).run() return result[0]
def testGarbageCollection(self): # Make a class that holds onto a reference to a channel # and then block it on that channel. tc = TaskletChannel() t = stackless.tasklet(tc.run)() t.run() # Pickle the tasklet that is blocking. s = pickle.dumps(t) # Unpickle it again, but don't hold a reference. pickle.loads(s) # Force the collection of the unpickled tasklet. gc.collect()