[Stackless] send_sequence doesn't pickle

Matt Provost mprovost at termcap.net
Thu Mar 22 00:28:18 CET 2007


I found out the hard way that channel.send_sequence doesn't pickle. I'm
not sure if this is a bug or a limitation but maybe this will save
someone some time. It would be nice if it worked though since
send_sequence is really handy. I might take a look at the source a
little deeper but possibly someone already knows why this doesn't work.

Here's some example code:

import stackless
import pickle

ch = stackless.channel()

def sequence_send(channel):
        list = []
        x = 0
        while x < 100:
                x = x + 1
                list.append(x)
        channel.send_sequence(list)

def iter_send(channel):
        x = 0
        while True:
                x = x + 1
                channel.send(x)

def receiver(channel):
        for x in xrange(10):
                y = channel.receive()
                print y

#sender = stackless.tasklet(sequence_send)(ch)
sender = stackless.tasklet(iter_send)(ch)

stackless.tasklet(receiver)(ch)
stackless.run()

pickled_sender = pickle.dumps(sender)


If you switch to using sequence_send, you'll get a stack trace like
this:

Traceback (most recent call last):
  File "./test6.py", line 33, in <module>
    pickled_sender = pickle.dumps(sender)
  File "/usr/local/stackless/lib/python2.5/pickle.py", line 1401, in dumps
    Pickler(file, protocol).dump(obj)
  File "/usr/local/stackless/lib/python2.5/pickle.py", line 231, in dump
    self.save(obj)
  File "/usr/local/stackless/lib/python2.5/pickle.py", line 338, in save
    self.save_reduce(obj=obj, *rv)
  File "/usr/local/stackless/lib/python2.5/pickle.py", line 426, in save_reduce
    save(state)
  File "/usr/local/stackless/lib/python2.5/pickle.py", line 293, in save
    f(self, obj) # Call unbound method with explicit self
  File "/usr/local/stackless/lib/python2.5/pickle.py", line 569, in save_tuple
    save(element)
  File "/usr/local/stackless/lib/python2.5/pickle.py", line 293, in save
    f(self, obj) # Call unbound method with explicit self
  File "/usr/local/stackless/lib/python2.5/pickle.py", line 607, in save_list
    self._batch_appends(iter(obj))
  File "/usr/local/stackless/lib/python2.5/pickle.py", line 622, in _batch_appends
    save(x)
  File "/usr/local/stackless/lib/python2.5/pickle.py", line 313, in save
    rv = reduce(self.proto)
ValueError: frame exec function at 08125508 is not registered!

Thanks,
Matt

_______________________________________________
Stackless mailing list
Stackless at stackless.com
http://www.stackless.com/mailman/listinfo/stackless



More information about the Stackless mailing list