在查看线程对象的python文档时,它对守护进程线程有一个注释,其中写道:
Daemon threads are abruptly stopped at shutdown. Their resources (such as open files, database transactions, etc.) may not be released properly. If you want your threads to stop gracefully, make them non-daemonic and use a suitable signalling mechanism such as an Event.
那我们为什么要用它们呢?在
Python尝试在退出时加入非守护进程线程。如果没有实现终止它们的机制,python将挂起。令人恼火的是,ctrl-C通常不起作用,您必须在外部终止程序。在
相关问题 更多 >
编程相关推荐