Find the current line number of a running python process

Viewed 1036

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?

1 Answers

Seems like py-spy is what you are looking for.

It can connect to running process without modifying and show what it currently do.

Related