Python Terminated Thread Cannot Restart

家住魔仙堡 提交于 2019-12-05 05:57:27

Threads cannot be restarted. You must re-create the Thread in order to start it again.

GHHT

From the Python documentation: start() starts the thread's activity. This must be called at most once per thread object. It arranges for the object's run()method to be invoked in a separate thread of control.

If you derive a class from threading.Thread you can add a Thread.__init__(self) at the end of your run method and you'll be able to call start again and it'll automatically reinitialize itself when done.

You can try setting

thread._Thread__started = False

It isn't officially documented, so use it on your own risk! :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!