[Stackless] Catching exception from tasklets

Richard Tew richard.m.tew at gmail.com
Sat Jun 23 20:30:00 CEST 2012


On Sat, Jun 23, 2012 at 6:51 PM, Lars van Gemerden <lars at rational-it.com> wrote:
>  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?

Why you are getting an exception printed is unclear from the code you
have provided.  You would need to provide a reproduction case so the
problem could be observed.  Or at the least, the exception trace given
it is some Stackless caused problem and not a side-effect of your
code.

> 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 ;-) ?

You can empty the scheduler by enumerating the tasklets in the
scheduler.  This can be done by getting the current tasklet (t =
stackless.current) and stepping through the chain of scheduled
tasklets (t.next, t.next.next, t.next.next.next...).

The following code is untested and may not work:

  ct = stackless.current
  while ct.next is not ct:
      ct.next.kill()

> I am working (since today) with Wingware as IDE (the only IDE with stackless
> debug support?)

Yes.

Cheers,
Richard.



More information about the Stackless mailing list