博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
How to exit the entire application from a Python thread?
阅读量:6500 次
发布时间:2019-06-24

本文共 635 字,大约阅读时间需要 2 分钟。

If all your threads except the main ones are daemons, the best approach is generally -- any thread can use it to raise a KeyboardInterrupt in the main thread, which can normally lead to reasonably clean exit from the main thread (including finalizers in the main thread getting called, etc). Of course, if this results in some non-daemon thread keeping the whole process alive, you need to followup with os._exit as Mark recommends -- but I'd see that as the last resort (kind of like a kill -9;-) because it terminates things quite brusquely (finalizers not run, including try/finally blocks, with blocks, atexit functions, etc, etc).

转载地址:http://twtyo.baihongyu.com/

你可能感兴趣的文章
pbrun
查看>>
浏览器加载和渲染网页顺序
查看>>
微服务架构springcloud
查看>>
深入剖析Android系统试读样章
查看>>
测试用例出错重跑--flaky插件
查看>>
yaf的安装
查看>>
比较java与C++的不同
查看>>
Twitter Storm入门
查看>>
使用scikit-learn进行文本分类
查看>>
Ansible自动化运维配置与应用(结合实例)
查看>>
下面简要介绍软件工程的七条原理
查看>>
java POI实现excel实现表格导出
查看>>
Lua(三)——语句
查看>>
TensorFlow的基本运算01
查看>>
怎么看电脑有没有安装USB3.0驱动
查看>>
overflow清除浮动的原理
查看>>
Spring Boot 使用parent方式引用时 获取值属性方式默认@
查看>>
解决maven下载jar慢的问题(如何更换Maven下载源)
查看>>
linux安装gitLab
查看>>
concurrent包的实现示意图
查看>>