[Stackless] Catching exception from tasklets

Lars van Gemerden lars at rational-it.com
Sat Jun 23 08:51:54 CEST 2012



> 
> 
> Hello Stackless,
> 
> 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.
> 
> I have been working with stackless for a couple of days and i noticed something strange with exceptions:
> 
> -----------------------------------------------------------------------------------------------
> class TaskletManager(object):
>     
>     schedule_channel = stackless.channel()
>     schedule_channel.preference = 1
>     
>     @classmethod
>     def mainloop(cls, world):
>         cls.world = world.instance() # <= creates tasklets
>         cls.world.command = 'GO'
>         try:
>             while True:
>                 stackless.run() # <= somewhere an exception is raised and not caught by my code
>                 cls.reschedule()
>         except Exception, e:
>             print 'stackless ended by Exception:\n', e .message   # <= doesn't catch exception
>     
>     @classmethod
>     def schedule(cls): 
>         cls.schedule_channel.receive()    
>     
>     @classmethod
>     def reschedule(cls):
>         while cls.schedule_channel.balance < 0:
>             cls.schedule_channel.send(None)
> -------------------------------------------------------------------------------------------------
> 
>  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.
> 
> Why does this happen?
> 
> 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 ;-) ? 
> 
> I am working (since today) with Wingware as IDE (the only IDE with stackless debug support?)
> 
> Cheers, Lars
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.stackless.com/pipermail/stackless/attachments/20120623/3a01b9bb/attachment.html>


More information about the Stackless mailing list