Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d46b410

Browse files
committed
Python: CG trace: Proper exception handling
1 parent 10ec1e0 commit d46b410

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

  • python/tools/recorded-call-graph-metrics/src/cg_trace

python/tools/recorded-call-graph-metrics/src/cg_trace/tracer.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,10 @@ def run(self, code, globals, locals):
164164
try:
165165
sys.setprofile(self.profilefunc)
166166
exec(code, globals, locals)
167-
# TODO: exception handling?
168-
finally:
169167
sys.setprofile(None)
168+
except Exception:
169+
sys.setprofile(None)
170+
LOGGER.info("Exception occurred while running program:", exc_info=True)
170171

171172
def profilefunc(self, frame: FrameType, event: str, arg):
172173
# ignore everything until the first call, since that is `exec` from the `run`

0 commit comments

Comments
 (0)