Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (47.6k 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 (106k 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 (4k 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

Browse Categories

...