[Twisted-Python] Tracebacks being dropped from exceptions when using inlineCallbacks

Terry Jones terry at jon.es
Fri Jan 16 17:51:16 MST 2009


Hi Phil

>>>>> "Phil" == Phil Christensen <phil at bubblehouse.org> writes:
Phil> On Jan 12, 2009, at 8:36 PM, Terry Jones wrote:
>> # added 2003-06-23. See comment above in __init__
>> c['tb'] = None
>> 
>> But the comment in __init__ seems to have been deleted.

Phil> The comment was this:

Phil> # added 2003-06-23 by Chris Armstrong. Yes, I actually have a
Phil> # use case where I need this traceback object, and I've made
Phil> # sure that it'll be cleaned up.
Phil> self.tb = tb

I'd seen that comment, and even the same date on it, but assumed there was
more detail in __init__.  I don't know what Chris' use case was, but we
definitely have another one now.

I don't really understand the comment in any case. If someone creates a
Failure instance by explicitly passing in all of exc_value, exc_type, and
exc_tb - with the probable intention that this failure instance is passed
along an errback chain - then I think it's reasonable for them to expect
the Failure will keep the tb and not toss it.

I may well be misunderstanding things, but I don't see how there can be any
question that the self.tb = tb line is desirable.

Phil> Originally all __getstate__ did was stringify the object's state,
Phil> which is probably why cleanFailure calls it directly. It looks to me
Phil> like most of the code from __getstate__ should really be moved into a
Phil> separate method, which would be called from cleanFailure as well as
Phil> __getstate__.

That sounds fine to me.

If I understand you and the code correctly, the only reason for calling
cleanFailure is to reduce the number of references to other objects, thus
clearing the way for garbage collection that would not otherwise happen. Is
that right?

Phil> I'd appreciate any feedback.

And thanks a lot for yours. It would be very useful to get this fixed. I'm
happy to submit a patch, though your suggested change looks like a couple
of minutes' work (just swapping the names of the cleanFailure and
__getstate__ methods gets you almost all the way there).

Terry




More information about the Twisted-Python mailing list