You can print out a nice stack trace using pyrasite.
First, you'll need to have gdb installed.
# Redhat, CentOS, etc
$ yum install gdb
# Ubuntu, Debian, etc
$ apt-get update && apt-get install gdb
Then, install pyrasite.
$ pip install pyrasite
Use ps
or some other method to find the process ID for the stuck python process and run pyrasite-shell
with it.
# Assuming process ID is 12345
$ pyrasite-shell 12345
You should now see a python REPL. Run the following in the REPL to see stack traces for all threads.
import sys, traceback
for thread_id, frame in sys._current_frames().items():
print 'Stack for thread {}'.format(thread_id)
traceback.print_stack(frame)
print ''
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…