守护进程线程在Python3.5.1中有何用处?

2024-09-30 06:21:45 发布

您现在位置:Python中文网/ 问答频道 /正文

在查看线程对象的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.

那我们为什么要用它们呢?在


Tags: 对象文档进程as线程areatdaemon
1条回答
网友
1楼 · 发布于 2024-09-30 06:21:45

Python尝试在退出时加入非守护进程线程。如果没有实现终止它们的机制,python将挂起。令人恼火的是,ctrl-C通常不起作用,您必须在外部终止程序。在

相关问题 更多 >

    热门问题