[Twisted-Python] lost tracebacks?

Alec Flett alecf at metaweb.com
Tue Dec 9 19:41:50 EST 2008


So I am constantly "losing" my tracebacks when my defer's callbacks  
throw exceptions that aren't caught. When I get an uncaught exception  
(caught via twisted.log.addObserver()) I am basically storing the  
Failure instance and then later, when it's safe for me to do so,  
calling fail.raiseException() - but the Failure's 'tb' property is None.

I traced this down to the code in Deferred._runCallbacks() which does  
a try: / except: with::

     self.result = failure.Failure()

Seems like this code should say::

     exc_type, exc_value, exc_traceback = sys.exc_info()
     self.result = failure.Failure(exc_value, exc_type, exc_traceback)


I'm dealing with two issues:
1) trying to generically log stack traces that happen
2) provide sane stack traces to my team who is fairly new to twisted

I can see how this might possibly leak if the tracebacks are holding  
onto references to local variables or something, but maybe  
cleanFailure() fixes that? I don't know.

Alec




More information about the Twisted-Python mailing list