How do you find out what's happening in a process?

L

Leo Jay

Hi all,

I'd like to know how do you guys find out what's happening in your
code if the process seems not work.
In java, I will use jstack <pid> to check stacks of threads and lock status.
But I don't know how to do it in python.
 
U

Ulrich Eckhardt

Leo said:
I'd like to know how do you guys find out what's happening in your
code if the process seems not work.
In java, I will use jstack <pid> to check stacks of threads and lock
status. But I don't know how to do it in python.

import pdb
pdb.set_trace()

Generally, searching "python debugger howto" should turn up a few useful
results. ;)

Uli
 
M

Michele Simionato

Hi all,

I'd like to know how do you guys find out what's happening in your
code if the process seems not work.
In java, I will use jstack <pid> to check stacks of threads and lock status.
But I don't know how to do it in python.

If you give a CTRL-C the Python process will die with a traceback
showing the line where the process
got stuck (assuming you started it from the command-line). You can
even run the script under the debugger and give a CTRL-C after a
while, as follows:

$ python -m pdb thescript.py
(Pdb) c
<wait a bit ...>
CTRL-C
Traceback ...
...
(Pdb) <inspect the variables and continue if you like>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,161
Messages
2,570,892
Members
47,428
Latest member
RosalieQui

Latest Threads

Top