[MERGE] add stracing of specific functions support

Robert Collins robertc at robertcollins.net
Mon Mar 26 21:27:21 BST 2007


On Mon, 2007-03-26 at 09:13 -0500, John Arbash Meinel wrote:
> Robert Collins wrote:


> > Hmm. I dont really like this. We can pass the callable result back if
> > you like, I don't object to that, but catching all exceptions like so -
> > blech. If we pass the result back it should be 
> >   return result, StraceResult(log)
> > because thats the style our lsprof wrapper returns in.
> > 
> >> I'm pretty strong on being able to get the return value of the function,
> >> not so much about the exception. And I'm otherwise +1 on having this
> >> included.
> > 
> > Rob
> > 
> 
> Well, sometimes the thing you want to trace is raising an exception.
> 
> What *I've* wanted to do with lsprof is be able to run maybe 10
> iterations and then stop, but there isn't really a good way to do that
> (since the exception causes .profile() to not return).
> 
> As I said, I'm not stuck on the exception grabbing. But it could really
> be nice if there were a way to do it. As you may be trying to use strace
> to figure out why an exception is being raised. I agree that it is ugly,
> so I wouldn't require it. I just don't see a better way.

def catch_anything_callable(thing_to_call, *args, **kwargs):
    try:
        thing_to_call(*args, **kwargs)
    except:
        pass

...
_, strace_result = strace.strace(catch_anything_callable,
function_that_blowsup, arg, arg, arg=blargh)

-Rob


-- 
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20070327/278e5abd/attachment-0001.pgp 


More information about the bazaar mailing list