Hi Folks:
I am exploring ways of detaching a blocked tasklet from a channel and attach it
to a different channel and then resume it. I wrote the following sample code:
#!/usr/bin/env python
import stackless
class Process(object):
def __init__(self, channel):
self.channel = channel
def execute(self):
print self.channel.receive()
channel = stackless.channel()
x = Process(channel)
t = stackless.tasklet(x.execute)()
stackless.schedule()
print "object channel", x.channel
print "tasklet channel", t._channel
newChannel = stackless.channel()
x.channel = newChannel
print "object channel", x.channel
print "tasklet channel", t._channel
t._channel = newChannel
newChannel.send("testing")
stackless.run()
I get the following result:
object channel <stackless.channel object at 0x00BF54B0>
tasklet channel <stackless.channel object at 0x00BF54B0>
object channel <stackless.channel object at 0x00BF54E0>
tasklet channel <stackless.channel object at 0x00BF54B0>
File "C:\lab\Adventures-Example\serialization.py", line 21, in <module>
t._channel = newChannel
AttributeError: attribute '_channel' of 'tasklet' objects is not writable
Why is _channel not writable? Is it owned by the scheduler?
Cheers,
Andrew
_______________________________________________
Stackless mailing list
[email protected]
http://www.stackless.com/mailman/listinfo/stackless