Created
February 2, 2022 17:40
-
-
Save Starou/065a5c53c612ed7099ec07f3504c42b5 to your computer and use it in GitHub Desktop.
Trace function calls in a Python program but ignore standard and site-packages lib calls.
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
import sys | |
import trace | |
tracer = trace.Trace( | |
ignoredirs=[ | |
'/usr/local/lib/python3.6', # adapt to your environment. | |
'/path/to/lib/python3.6/site-packages', | |
], | |
trace=1, | |
count=0, | |
outfile=sys.stdout | |
) | |
# Use that instead of my_function(arg_1, arg_2) | |
tracer.runfunc(my_function, arg_1, arg_2) | |
def my_function(foo, bar): | |
# Do stuff |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment