Reputation: 29655
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?
Upvotes: 12
Views: 2113
Reputation: 451
Seems like py-spy is what you are looking for.
It can connect to running process without modifying and show what it currently does by using the command:
py-spy dump --pid 12345
Upvotes: 10