[Stackless] How to check for errors after calling PyStackless_Schedule()
richard.m.tew at gmail.com
Sun Jan 18 16:23:44 CET 2009
On Sun, Jan 18, 2009 at 1:44 AM, Lindell Alderman
<lindell.alderman at gmail.com> wrote:
> Hello all! I am embedding stackless inside of a libev event loop. I have
> callback functions that get run on idle and at the top of each loop that
> call PyStackless_Schedule(). My problem is that I can't figure out how to
> catch exceptions raised by tasklets and print them out.
> In standard python c api, I would expect to just call PyErr_Occurred() and
> then PyErr_Fetch(). But PyErr_Occurred seems to always return NULL after
> calling PyStackless_Schedule(). Any suggestions?
Errors which occur in tasklets do not get raised outside the scheduler.
Standard practice in my experience is to launch a wrapper function
which calls the code you want to run in a tasklet. The wrapper then
catches exceptions and deals with them as you wish to have them dealt
Keep in mind that there are exceptions you should never catch and
should reraise if you catch them. TaskletExit, SystemExit and perhaps
other OS and internal Python operational ones.
More information about the Stackless