<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&nbsp;&nbsp;&nbsp;&nbsp; <br>_unit_A = stackless.channel()<br>_unit_B = stackless.channel()<br>_unit_C = stackless.channel()<br><br>class units:<br>&nbsp; def __init__(self,channel,name):<br>&nbsp;&nbsp;&nbsp; self.ch = channel<br>&nbsp;&nbsp;&nbsp; self.name = name<br>&nbsp;&nbsp;&nbsp; stackless.tasklet(self.process)()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp; def process(self):<br>&nbsp;&nbsp;&nbsp; print self.name,"Unit running"<br>&nbsp;&nbsp;&nbsp; while True:&nbsp;&nbsp;&nbsp;
 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; msg = self.ch.receive()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if msg == "exit":<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print self.name,":",msg<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stackless.schedule()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>def testit():<br>&nbsp; print "Testing the parallel tasks"<br>&nbsp; units(_unit_A,"unit A")<br>&nbsp; units(_unit_B,"unit B")&nbsp; <br>&nbsp; units(_unit_C,"unit C")&nbsp; <br>&nbsp; msg = "Msg from unit A who says hello"<br>&nbsp; _unit_B.send(msg)<br>&nbsp; stackless.run()&nbsp; <br>&nbsp;&nbsp;&nbsp; <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:\&gt;<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:\&gt;<br><br>&nbsp;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>