Created
July 27, 2018 03:10
-
-
Save zhu327/3749a3f6249b58f9c508714e75382608 to your computer and use it in GitHub Desktop.
Python调用栈跟踪
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
from __future__ import print_function | |
import re | |
import sys | |
filter = re.compile(r'site-packages/requests/.*') | |
def tracer(frame, event, args): | |
if filter.search(frame.f_code.co_filename): | |
print({ | |
'event': event, | |
'filename': frame.f_code.co_filename, | |
'lineno': frame.f_lineno, | |
'context': frame.f_code.co_name | |
}) | |
return tracer | |
sys.settrace(tracer) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment