How can I tell where my python script is hanging?

后端 未结 13 767
醉话见心
醉话见心 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:37

    Nothing like the good old pdb

    import pdb
    pdb.run('my_method()',globals(),locals())
    

    Then just hit (n) to go to the next command, (s) to step into. see the docs for the full reference. Follow your program step by step, and you'll probably figure it out fast enough.

提交回复
热议问题