閱讀http://bugs.python.org/msg160297,我可以看到由斯蒂芬·懷特寫了一個簡單的腳本演示瞭如何蟒蛇線程錯誤了這個異常瞭解蟒蛇線程錯誤
Exception AttributeError: AttributeError("'_DummyThread' object has no attribute '_Thread__block'",) in <module 'threading'
鑑於斯蒂芬·懷特的源代碼(HTTP://bugs.python .ORG/file25511/bad-thread.py),
import os
import thread
import threading
import time
def t():
threading.currentThread() # Populate threading._active with a DummyThread
time.sleep(3)
thread.start_new_thread(t,())
time.sleep(1)
pid = os.fork()
if pid == 0:
os._exit(0)
os.waitpid(pid, 0)
如何將我們把它重新寫那麼這個錯誤得到解決?
在我看來,你可以將它全部重寫爲'time.sleep(3)'。我想你應該指定重寫的程序應該實際執行的操作。 –
@JanneKarila該程序僅僅演示了一個Python bug,如果你在Python 2.7中運行它,你會看到它。這個請求是爲了解決這個bug而不是升級到修復它的Python版本。 – user4815162342