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?
One thing that distinguishes Python from other programming languages is that it is interpreted rather than compiled. This means that it is executed line by line, which allows programming to be interactive in a way that is not directly possible with compiled languages like Fortran, C, or Java.
Seems like py-spy is what you are looking for.
It can connect to running process without modifying and show what it currently do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With