There is nothing as convenient and direct to use as jstack. Generally speaking, there are several solutions:
IDE: Use tools such as PyCharm, Eclpise with Pydev to debug, pause and check each call stack when you feel it hangs.
GDB: The advantage is that you can debug the native extension. The disadvantage is also obvious. You need to add Debug Symbols when compiling Python. This is not available by default. To put it simply, it is powerful but not worth the trouble.
pdb: Suitable for lower breakpoints...
pudb: Change the code. At the program entry import pudb; pudb.set_interrupt_handler(), you can press Ctrl-C to enter the interactive debugging environment when running. The ease of use is not bad.
Use a singal handler to print all stack information. Refer to the install_cry_handler implemented by celery, or look at signalhandler, which comes with Python 3.3.
NOTE: One disadvantage of all solutions that rely on signal is that many POSIX functions will return EINTR when these interrupts are generated, directly causing Python exceptions, such as send, recv, read, write etc. . .
It seems that it is not possible to use multi-threading directly in python because there is something called GIL. As for if you want to see the thread situation, you can use pdb to debug. Try it
There is nothing as convenient and direct to use as jstack. Generally speaking, there are several solutions:
import pudb; pudb.set_interrupt_handler()
, you can press Ctrl-C to enter the interactive debugging environment when running. The ease of use is not bad.celery
, or look at signalhandler, which comes with Python 3.3.NOTE: One disadvantage of all solutions that rely on signal is that many POSIX functions will return EINTR when these interrupts are generated, directly causing Python exceptions, such as
send
,recv
,read
,write
etc. . .I don’t know Java, so I don’t know what you want. Do you want to print out the call stacks of all threads? It doesn't seem to be easy.
I am usually:
It seems that it is not possible to use multi-threading directly in python because there is something called GIL. As for if you want to see the thread situation, you can use pdb to debug. Try it