On Sun, Jan 18, 2009 at 1:44 AM, Lindell Alderman
<[email protected]> 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
with.

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.

Cheers,
Richard.

_______________________________________________
Stackless mailing list
[email protected]
http://www.stackless.com/mailman/listinfo/stackless

Reply via email to