简体   繁体   English

找到正在运行的python进程的当前行号

[英]Find the current line number of a running python process

I have long-running python programs that do not have sufficient internal logging. 我有长期运行的python程序,没有足够的内部日志记录。 I'd like to be able to attach to a running python program and find out it's current line number. 我希望能够附加到正在运行的python程序并找出它的当前行号。 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. 我可以很容易地键入control-C,但这会杀死程序。

Is there any way to do this? 有没有办法做到这一点?

Seems like py-spy is what you are looking for. 好像py-spy就是你要找的东西。

It can connect to running process without modifying and show what it currently do. 它可以连接到正在运行的进程而无需修改并显示它当前的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM