Check what a running process is doing: print stack trace of an uninstrumented Python program

Björn Lindqvist picture Björn Lindqvist · Jul 27, 2011 · Viewed 7.7k times · Source

Is there a way on Linux to check what a running Python daemon process is doing? That is, without instrumenting the code and without terminating it? Preferably I'd like to get the name of the module and the line number in it that is currently running.

Conventional debugging tools such as strace, pstack and gdb are not very useful for Python code. Most stack frames just contain functions from the interpreter code like PyEval_EvalFrameEx and and PyEval_EvalCodeEx, it doesn't give you any hint on were in the .py-file the execution is.

Answer

Nickolay picture Nickolay · Apr 26, 2015

Some of the answers in Showing the stack trace from a running Python application are applicable in this situation: