I was debugging a problem in a codebase I’m none too familiar with this evening and decided it was high time I learned how to generate a callgraph in python. A very brief Google search landed me here http://stefaanlippens.net/python_inspect, and a commenter had exactly what I needed:
+ import inspect + bb.plain(" << ".join([i for i in inspect.stack()[1:-4]]))
Which generates a very simple call graph:
parse << parse_file << worker << run << _bootstrap << __init__ << start << __init__ << Pool << start << __init__ << updateCache << runAsyncCommand << runCommands << idle_commands << waitEvent << main
Awesome module, thanks for the blog, and thanks for the comment!