<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi I am a newbi to stakless. I have read the documentaion specially the piece by grant olson.<br><br>I want to create three tasks which are continually waiting for messages and don not die until they recieve the "exit" message. I have written the code below:<br><br>import os, sys<br>import stackless<br>import math<br><br>global _unit_A, _unit_B, _unit_C <br>_unit_A = stackless.channel()<br>_unit_B = stackless.channel()<br>_unit_C = stackless.channel()<br><br>class units:<br> def __init__(self,channel,name):<br> self.ch = channel<br> self.name = name<br> stackless.tasklet(self.process)()<br> <br> def process(self):<br> print self.name,"Unit running"<br> while True:
<br> msg = self.ch.receive()<br> if msg == "exit":<br> return<br> print self.name,":",msg<br> stackless.schedule()<br> <br>def testit():<br> print "Testing the parallel tasks"<br> units(_unit_A,"unit A")<br> units(_unit_B,"unit B") <br> units(_unit_C,"unit C") <br> msg = "Msg from unit A who says hello"<br> _unit_B.send(msg)<br> stackless.run() <br> <br><br>testit()<br><br><br>But when I run it, it runs through all tasks once and the program finishes and I get this.<br><br>c:\><br>Testing the parallel tasks<br>unit A Unit running<br>unit B Unit running<br>unit B : Msg from unit A who says hello<br>unit C Unit running<br>c:\><br><br> I am sure it must be
something simple, but cant figure it out. Does anybody know what is happening here and what I am doing wrong?<br><br>cheers<br>tomcat<br></td></tr></table>