[Stackless] send_sequence doesn't pickle

Richard Tew richard.m.tew at gmail.com
Sun Mar 25 19:55:07 CEST 2007


On 3/21/07, Matt Provost <mprovost at termcap.net> wrote:
> 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.

I have a patch which does the trick.  But I need to check it over before
I commit it.

>>> 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)
>>> stackless.tasklet(receiver)(ch)
<stackless.tasklet object at 0x00C43FB0>
>>> stackless.run()
1
2
3
4
5
6
7
8
9
10
>>> v = pickle.dumps((ch, sender))
>>> ch2, sender2 = pickle.loads(v)
>>> stackless.tasklet(receiver)(ch2)
<stackless.tasklet object at 0x00C43FB0>
>>> stackless.run()
11
12
13
14
15
16
17
18
19
20
>>>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sendseq.patch
Type: application/octet-stream
Size: 1405 bytes
Desc: not available
URL: <http://www.stackless.com/pipermail/stackless/attachments/20070325/e86080f2/attachment.obj>
-------------- next part --------------
_______________________________________________
Stackless mailing list
Stackless at stackless.com
http://www.stackless.com/mailman/listinfo/stackless


More information about the Stackless mailing list