report all exceptions #1021

Open
opened 2010-04-13 04:21:27 +00:00 by zooko · 2 comments
zooko commented 2010-04-13 04:21:27 +00:00
Owner

I'm not sure, but it seems like sometimes an exception can be raised from our code or from some libraries that we use and that exception silently vanishes instead of being logged. There is an allegation of this happening in #710 and in #807. Brian: is this possible? How would an exception get caught and not get logged?

I'm not sure, but it seems like sometimes an exception can be raised from our code or from some libraries that we use and that exception silently vanishes instead of being logged. There is an allegation of this happening in #710 and in #807. Brian: is this possible? How would an exception get caught and not get logged?
tahoe-lafs added the
code
major
defect
1.6.1
labels 2010-04-13 04:21:27 +00:00
tahoe-lafs added this to the eventually milestone 2010-04-13 04:21:27 +00:00
zooko commented 2010-04-13 04:35:12 +00:00
Author
Owner

Well I guess the next step, aside from asking Brian to give his opinion on the topic, is to take #710 and #807 and try to turn them into reproducible test cases -- insert an exception-raising statement into the appropriate part of the code (maybe using voidspace mock lib which I like http://www.voidspace.org.uk/python/mock/ ) and then check whether that exception got logged properly.

Well I guess the next step, aside from asking Brian to give his opinion on the topic, is to take #710 and #807 and try to turn them into reproducible test cases -- insert an exception-raising statement into the appropriate part of the code (maybe using voidspace mock lib which I like <http://www.voidspace.org.uk/python/mock/> ) and then check whether that exception got logged properly.
davidsarah commented 2010-05-04 03:50:19 +00:00
Author
Owner

The following code (based on this article) prints all exceptions raised after it is run:

import sys

def trace_exceptions(frame, event, arg):
    if event != 'exception':
        return
    co = frame.f_code
    func_name = co.co_name
    line_no = frame.f_lineno
    filename = co.co_filename
    exc_type, exc_value, exc_traceback = arg
    print 'Tracing exception: %s "%s" on line %s of %s' % \
        (exc_type.__name__, exc_value, line_no, func_name)

def trace_calls(frame, event, arg):
    if event != 'call':
        return
    return trace_exceptions

sys.settrace(trace_calls)

The results are interesting but quite voluminous, and would need to be filtered.

The following code (based on [this article](http://www.doughellmann.com/PyMOTW/sys/tracing.html)) prints all exceptions raised after it is run: ``` import sys def trace_exceptions(frame, event, arg): if event != 'exception': return co = frame.f_code func_name = co.co_name line_no = frame.f_lineno filename = co.co_filename exc_type, exc_value, exc_traceback = arg print 'Tracing exception: %s "%s" on line %s of %s' % \ (exc_type.__name__, exc_value, line_no, func_name) def trace_calls(frame, event, arg): if event != 'call': return return trace_exceptions sys.settrace(trace_calls) ``` The results are interesting but quite voluminous, and would need to be filtered.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: tahoe-lafs/trac-2024-07-25#1021
No description provided.