[Twisted-Python] Failure is O(state) vs Exception

Andrew Bennetts andrew at bemusement.org
Wed Mar 30 04:39:50 EDT 2011

John Arbash Meinel wrote:
> > Just for the record, changing cleanFailure to not do its operation is
> > likely to lead to big memory leaks. The second thing you did, setting
> > self.tb to None, makes more sense to speed things up.
> Right. I agree that it is a better solution. I was wondering about
> having a whitelist of Exception classes that aren't considered
> interesting enough to keep a traceback.

I've filed <http://twistedmatrix.com/trac/ticket/5011> about this issue,
and I have a patch that takes an alternative approach: don't capture
tracebacks when Deferred callbacks raise exceptions unless
defer.setDebugging(True) has been called.

Another possibility might be to stop Failure from capturing all the
frame details (i.e. the locals and globals) by default (or at least when
invoked by Deferred._runCallbacks), as that's probably the bulk of the
expense and would be very rarely used.


More information about the Twisted-Python mailing list