查找正在运行的python进程的当前行号 [英] Find the current line number of a running python process
问题描述
我有长时间运行的python程序,没有足够的内部日志记录.我希望能够附加到正在运行的python程序,并找出它的当前行号.理想情况下,我希望在不中断其执行的情况下执行此操作,但是我很高兴让它暂停,打印堆栈t种族,然后继续前进.
我可以轻松键入control-C,但这会终止程序.
有什么办法吗?
好像 py-spy py-spy 是您要寻找的. p>
它可以连接到正在运行的进程,而无需修改并显示其当前操作.
I have long-running python programs that do not have sufficient internal logging. I'd like to be able to attach to a running python program and find out it's current line number. Ideally, I'd like to do this without interrupting its execution, but I'm happy to have it pause, print the stack t race, and then keep going.
I could easily type control-C, but that would kill the program.
Is there any way to do this?
Seems like py-spy is what you are looking for.
It can connect to running process without modifying and show what it currently do.
这篇关于查找正在运行的python进程的当前行号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!