查找正在运行的python进程的当前行号 [英] Find the current line number of a running python process

查看:78
本文介绍了查找正在运行的python进程的当前行号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有长时间运行的python程序,没有足够的内部日志记录.我希望能够附加到正在运行的python程序,并找出它的当前行号.理想情况下,我希望在不中断其执行的情况下执行此操作,但是我很高兴让它暂停,打印堆栈t种族,然后继续前进.

我可以轻松键入control-C,但这会终止程序.

有什么办法吗?

解决方案

好像 py-spy py-spy 是您要寻找的.

它可以连接到正在运行的进程,而无需修改并显示其当前操作.

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屋!

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