0 votes
1 view
in Python by (47.8k points)

I have this Python application that gets stuck from time to time and I can't find out where.

Is there any way to signal Python interpreter to show you the exact code that's running?

Some kind of on-the-fly stacktrace?

1 Answer

0 votes
by (107k points)

For showing the stack trace from a running Python application you can follow the below-mentioned steps:-

The first and most effective way to overcome this problem would be to install a signal handler. 

Sometimes you need to debug a process that I didn't have the foresight to install the signal handler in some of the os like, for Linux, you can attach gdb with the process and get a python stack trace with some gdb macros. 

For getting the gdb to use the following link:

 http://svn.python.org/projects/python/trunk/Misc/gdbinit in ~/.gdbinit, then:

  • Attach gdb: gdb -p PID

  • Get the python stack trace: pystack.

Related questions

0 votes
1 answer
asked Jul 9, 2019 in Java by Nigam (4.1k points)
0 votes
1 answer
asked Jul 9, 2019 in Java by Aditya98 (1.3k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...