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

前端 未结 5 1686
[愿得一人]
[愿得一人] 2021-02-07 02:07

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 t

5条回答
  •  你的背包
    2021-02-07 02:54

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

    • pyrasite (this was the one that worked for me):

      $ sudo pip install pyrasite
      $ echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
      $ sudo pyrasite 16262 dump_stacks.py # dumps stacks to stdout/stderr of the python program
      
    • pyringe

    • pydbattach - couldn't get this to work, but the repository https://github.com/albertz/pydbattach contains pointer to other tools
    • pstack reportedly prints the python stack on Solaris

提交回复
热议问题