检查正在运行的进程正在做什么:打印未跟踪的Python程序的堆栈跟踪 [英] Check what a running process is doing: print stack trace of an uninstrumented Python program

查看:489
本文介绍了检查正在运行的进程正在做什么:打印未跟踪的Python程序的堆栈跟踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在Linux上检查运行的Python守护进程正在做什么?也就是说,没有调用代码而不终止代码?最好我想得到当前正在运行的模块的名称和行号。



传统的调试工具(如strace,pstack和gdb)对Python代码不是很有用。大多数堆栈框架只包含解释器代码(如PyEval_EvalFrameEx和PyEval_EvalCodeEx)的函数,它不会在.py文件中给出任何提示。

解决方案

从正在运行的Python应用程序中显示堆栈跟踪适用于这种情况:




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.

解决方案

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

这篇关于检查正在运行的进程正在做什么:打印未跟踪的Python程序的堆栈跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆