How can I tell where my python script is hanging?

后端 未结 13 763
醉话见心
醉话见心 2020-12-04 08:10

So I\'m debugging my python program and have encountered a bug that makes the program hang, as if in an infinite loop. Now, I had a problem with an infinite loop before, but

13条回答
  •  自闭症患者
    2020-12-04 08:32

    Let's assume that you are running your program as:

    python YOURSCRIPT.py
    

    Try running your program as:

    python -m trace --trace YOURSCRIPT.py
    

    And have some patience while lots of stuff is printed on the screen. If you have an infinite loop, it will go on for-ever (halting problem). If it gets stuck somewhere, then mostly you are stuck on I/O or it is a deadlock.

提交回复
热议问题