launchpad-dev team mailing list archive
-
launchpad-dev team
-
Mailing list archive
-
Message #06791
Re: [performance] Twisted Exception "features"
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
...
>> I believe there are things like Failure.trap() and xmlrpc.trap_fault()
>> that can do a bare 'raise' to re-raise the original exception because it
>> doesn't match the exact type that the error handler can handle.
>
> Neither of those is a problem, although I had to check earlier today to
> be sure :)
>
> Failure.trap() will re-raise the original Failure (it's an old-style
> class, which Python allows to be raised, like how it allows you to raise
> strs). Calling Failure() when the active exception is a Failure does
> some magic that ends up setting self.__dict__ = raised_failure.__dict__,
> so the result of Failure() in that case doesn't have self.tb set if the
> original failure didn't either.
>
> lp.services.twistedsupport.xmlrpc.trap_fault is the same: the only thing
> it raises is the failure given to it (either via Failure.trap or
> directly). So it's ok too.
>
Right. So I added the tracing with
"mutter(''.join(traceback.format_stack()))" whenever Failure has a tb.
And it looks like it is always happening in the DeferredBlockingProxy
case. I think we can easily trap that one.
However, the timings I see make me wonder if the same thing is also
happening in the XMLRPC *server*. Because with your patch, I thought the
xmlrpc times were actually too high, and re-ran it about 10 times to
make sure I wasn't seeing things.
So doing "Failure.__init__ tb=None" was also having an effect on the
xmlrpc side, I just don't see that from the bzr-forker log file. I'll
try to update my instrumentation and see if I see anything on the xmlrpc
side.
>> At least as I read that, if you pass an object for 'exc_value' but pass
>> None for 'exc_tb' it will find the traceback from sys.exc_info. I have
>> to actually audit the code to make sure that is the case.
>
> I have two strong pieces of evidence that my understanding is correct.
>
> 1) my patch sped up your benchmark :)
>
> 2)
>>>> from twisted.python.failure import Failure
>>>> try:
> ... 1/0
> ... except ZeroDivisionError as e:
> ... f = Failure(e)
> ... f2 = Failure()
> ...
>>>> print f.tb
> None
>>>> f2.tb
> <traceback object at 0xb7508d4c>
>
> -Andrew.
>
Yeah, I walked through the code as well. The documentation seems to hint
at it, but it certainly doesn't happen that way.
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk2RyZAACgkQJdeBCYSNAAPGgwCfeg0dx0s0uRaJ17P6ZPzws6Bj
0ygAn0iqX/l1bEX5vSuoDpm1yZJZwy07
=21Jc
-----END PGP SIGNATURE-----
Follow ups
References