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

Michele Simionato michele.simionato at gmail.com
Mon Nov 29 11:53:09 EST 2010


On Nov 29, 7:01 am, Leo Jay <python.leo... at gmail.com> wrote:
> 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.
>
> --
> Best Regards,
> Leo Jay

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>



More information about the Python-list mailing list