Threaded importing while interpreter shuts down

巧了我就是萌 提交于 2019-12-19 04:17:33

问题


Python's threading documentation states:

All import attempts must be completed before the interpreter starts shutting itself down. This can be most easily achieved by only performing imports from non-daemon threads created through the threading module. Daemon threads and threads created directly with the thread module will require some other form of synchronization to ensure they do not attempt imports after system shutdown has commenced. Failure to abide by this restriction will lead to intermittent exceptions and crashes during interpreter shutdown (as the late imports attempt to access machinery which is no longer in a valid state).

I'm looking for example code that demonstrates this restriction.

来源:https://stackoverflow.com/questions/8456395/threaded-importing-while-interpreter-shuts-down

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