How can I tell where my python script is hanging?

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

    i = 0
    for t in threading.enumerate():
        if i != 0:# and t.getName() != 'Thread-1':
            print t.getName()
            t._Thread__stop()
        i += 1
    

    Once you know the names of the threads; start re-executing your script and filter them down, not stopping them from being aborted. i=0 conditional prevents the main thread from being aborted.

    I suggest going through and naming all your threads; such as: Thread(target=self.log_sequence_status, name='log status')

    This code should be placed at the end of the main program that starts up the run-away process

提交回复
热议问题