<html><head></head><body bgcolor="#FFFFFF"><div><br><br></div><blockquote type="cite"><div><font class="Apple-style-span" color="#000000"><br></font><br></div></blockquote><div></div><blockquote type="cite"><div><font size="1">Hello Stackless,</font><div><font size="1"><br></font></div><div><font size="1">This my first use of the stackless mailing list, so please let me know if the list is not for the kind of questions I am asking.</font></div>
<div><font size="1"><br></font></div><div><font size="1">I have been working with stackless for a couple of days and i noticed something strange with exceptions:</font></div><div><font size="1"><br></font></div><div><font size="1">-----------------------------------------------------------------------------------------------</font></div>
<div><font size="1">class TaskletManager(object):</font></div><div><font size="1">    </font></div><div><font size="1">    schedule_channel = stackless.channel()</font></div><div><font size="1">    schedule_channel.preference = 1</font></div>
<div><font size="1">    </font></div><div><font size="1">    @classmethod</font></div><div><font size="1">    def mainloop(cls, world):</font></div><div><font size="1">        cls.world = world.instance() # <= creates tasklets</font></div>
<div><font size="1">        cls.world.command = 'GO'</font></div><div><font size="1">        try:</font></div><div><font size="1">            while True:</font></div><div><font size="1">                stackless.run() # <= somewhere an exception is raised and not caught by my code</font></div>
<div><font size="1">                cls.reschedule()</font></div><div><font size="1">        except Exception, e:</font></div><div><font size="1">            print 'stackless ended by Exception:\n', e .message   # <= doesn't catch exception</font></div>
<div><font size="1">    </font></div><div><font size="1">    @classmethod</font></div><div><font size="1">    def schedule(cls): </font></div><div><font size="1">        cls.schedule_channel.receive()    </font></div><div>
<font size="1">    </font></div><div><font size="1">    @classmethod</font></div><div><font size="1">    def reschedule(cls):</font></div><div><font size="1">        while cls.schedule_channel.balance < 0:</font></div>
<div><font size="1">            cls.schedule_channel.send(None)</font></div><div><font size="1">-------------------------------------------------------------------------------------------------</font></div><div><font size="1"><br>
</font></div><div><font size="1"> Running "mainloop" above (based on the pumping pattern in the documentation) leads to a printout of the exception stack (uncaught in the code above). After that at least one tasklet keeps running.</font></div>
<div><font size="1"><br></font></div><div><font size="1">Why does this happen?</font></div><div><font size="1"><br></font></div><div><font size="1">In a related question, i am trying to define unit tests for my code, and between tests would like to kill/remove/empty the stackless scheduler, e.g. in tearDown. What is the easiest way to do this (the exception above seems not the way to go ;-) ? </font></div>
<div><font size="1"><br>
</font></div><div><font size="1">I am working (since today) with Wingware as IDE (the only IDE with stackless debug support?)
</font></div><div><font size="1"><br></font></div><div><font size="1">Cheers, Lars</font></div>
</div></blockquote></body></html>