change twisted.python.failure.Failure stack-saving semantics

[email protected] Sun, 07 Feb 2010 04:38:35 -0000
Newsgroups gmane.comp.python.twisted.bugs
Message-ID <[email protected]>
New submission from amckinley22 <[email protected]>:

Failure() currently serializes the scoped variables available in a traceback by invoking twisted.reflect.safe_repr(). This protects Twisted from circular references in the traceback, but has the unfortunate side effect of serializing a potentially large amount of stuff (basically, whatever was in scope when the exception was raised). I discovered this behavior after noticing that whenever my twisted process threw an exception, the entire reactor would hang for several seconds. After lots of debugging, I figured out that a very large cache object was being serialized on every exception, just because it happened to be in scope when the exception was raised.

I've attached a patch that modifies Failure.cleanFailure() to completely strip the locals/globals from Failure.stack and Failure.frame, instead of rendering them to strings. I've also added a deprecation warning when invoking Failure.printDetailedTraceback(), because that appears to be the only code that uses that info.

----------
Type     : defect
Component: core
Keywords : 
Priority : normal
Nosy     : 
----------
http://twistedmatrix.com/trac/ticket/4260