If all your threads except the main ones are daemons, the best approach is generally thread.interrupt_main() -- 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).

How to exit the entire application from a Python thread?的更多相关文章

  1. e611. Setting Focus Traversal Keys for the Entire Application

    This example changes the focus traversal keys for the entire application. For an example of how to c ...

  2. Environment.Exit(0) 、Application.Exit() 、this.Close() 、this.Dispose()的区别

    Application.Exit:通知winform消息循环退出.程序会等待所有的前台线程终止后才能真正退出.是一种强行退出方式,就像 Win32 的 PostQuitMessage().它意味着放弃 ...

  3. yum执行时Another app is currently holding the yum lock; waiting for it to exit... The other application is: yum

    可能是系统自动升级正在运行,yum在锁定状态中. 已经有一个yum进程在运行了,使用kill干掉它: # # ps aux|grep yum root pts/ S+ : : grep yum roo ...

  4. RuntimeError: Model class app_anme.models.User doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.---python学习错误记录

    untimeError: Model class app_anme.models.User doesn't declare an explicit app_label and isn't in an ...

  5. linux -小记(2)问题:yum 安装报错"Another app is currently holding the yum lock; waiting for it to exit... ...: yum Memory : 26 M RSS (868 MB VSZ) Started: Wed Oct 26 22:48:24 2016 - 0"

    yum 安装报错 "Another app is currently holding the yum lock; waiting for it to exit... The other ap ...

  6. 【转】 Android自定义捕获Application全局异常

    大家都知道,现在安装Android系统的手机版本和设备千差万别,在模拟器上运行良好的程序安装到某款手机上说不定就出现崩溃的现象,开发者个人不可能购买所有设备逐个调试,所以在程序发布出去之后,如果出现了 ...

  7. Controlling How NSThread and NSRunLoop Exit

    http://shaheengandhi.com/controlling-thread-exit/ While most concurrency can be dealt with by using ...

  8. Android Application Fundamentals——Android应用程序基础知识

    Application Fundamentals--应用程序基础知识 Key classes--关键类 Activity Service BroadcastReceiver ContentProvid ...

  9. Another app is currently holding the yum lock; waiting for it to exit 解决方法

    Another app is currently holding the yum lock; waiting for it to exit... The other application is: P ...

随机推荐

  1. MyEclipse文本对比界面样式修改

    MyEclipse刚安装好,使用文件对比的时候,发现两边的对比颜色非常浅,不同的地方不容易发现,可以通过以下配置将显示颜色调深一点. 配置 效果

  2. xcode7 调用相册权限无提示

    1) 打开工程的Info.pilst: 2) 把 Bundle name 和 Bundle display name 的 value值 ,改成跟项目app名一致: 这样系统才能正确地接收到调用请求

  3. API文档管理平台

    一.应用场景 在公司中,有很多开发,每个人维护的api接口是不一样的.如果有一个统一的api文档管理平台,每个开发,把自己维护的接口录入进去. 之后再开发别的功能时,不需要重复造轮子,直接调用就可以了 ...

  4. AARRR:数据运营模型

    一.基础知识 产品经理  <增长黑客>数据分析基础 -- 获取(Acquisition)-- 激活(Activation)-- 留存(Retention)-- 收入(Revenue)-- ...

  5. 【TensorFlow】一文弄懂CNN中的padding参数

    在深度学习的图像识别领域中,我们经常使用卷积神经网络CNN来对图像进行特征提取,当我们使用TensorFlow搭建自己的CNN时,一般会使用TensorFlow中的卷积函数和池化函数来对图像进行卷积和 ...

  6. windows7无声音,提示未插入扬声器或耳机的解决

    windows7无声音,提示未插入扬声器或耳机的解决: http://jingyan.baidu.com/article/358570f6043a85ce4624fc47.html

  7. linux查找文件或目录命令

    inux查找文件或目录命令,前提:知道文件或者目录的具体名字,例如:sphinx.conf find 查找  find / -name dirname  查找目录 find -name filenam ...

  8. Mysql自增语句

    一.创建查询 二.将 alter table `表名` change id id int not null auto_increment UNIQUE;复制进去(以id为例) 三.运行ok 注意:手动 ...

  9. TCP流嗅探和连接跟踪工具tcpick

    TCP流嗅探和连接跟踪工具tcpick   由于网络通信协议众多,TCP连接状态众多,所以TCP分析较为复杂.Kali Linux提供一款专用工具tcpick.该工具支持在线实时嗅探和离线文件嗅探.它 ...

  10. Swift2.0语言教程之下标脚本

    Swift2.0语言教程之下标脚本 下标脚本 下标脚本是访问对象.集合或者序列的快速方式.开发者不需要调用实例特定的赋值和访问方法,就可以直接访问所需要的数值.例如在数组中,可以直接使用下标去访问或者 ...