[Twisted-Python] How to find out if exceptions are being raised in your errBack?

Andrew Bennetts andrew at bemusement.org
Wed Oct 14 03:22:34 EDT 2009


Glyph Lefkowitz wrote:
[...]
>    I'm answering a question you didn't ask, about logged errors, because I
>    think it's the one you meant to ask.  The answer to the question you are
>    actually asking here, i.e. "how do I handle errors in an errback", is
>    quite simple: add another errback.  This is sort of like asking how to
>    handle exceptions in an 'except:' block in Python.  For example, if you
[...]

To think about it another way, what happens when an unhandled exception occurs
in a thread?  The thread dies, and Python simply throws the traceback at stderr.
There's not much else it can reasonably do.  If you want to catch (or suppress)
that error, you add (another) try/except at the outermost layer of the call
stack.

Possibly Twisted could provide some sort of last-ditch error reporting hook,
like sys.excepthook in core Python, but I'm not sure it would offer much
advantage over writing a log observer that looks for events where isError is
set.

-Andrew.




More information about the Twisted-Python mailing list