I’m using pycallgraph from the command line to profile and draw the call graph of a relatively simple program. However, the resulting image includes the internals of standard libraries (threading, json, socket) even though I don’t use the -s command line option. Using the -e option to exclude those modules has no effect and using -i results in an empty call graph. I’ve also tried cProfile, but it only graphs the main thread.
How can I make pycallgraph to only show calls in my code? The current messy result is useless.
Edit: I’m using 0.5.1, available via easy_install. Running pycallgraph ./cursesclient.py outputs this:
. As you can see, pycallgraph show the internals of modules json, re, encodings, socket and threading. Re and encodings are never even called directly in my code, but through json and socket, respectively.
pycallgraph has an undocumented stop_trace() method that you can use to exclude sections of code. Something like
Is that what you’re after?
source