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. 32 Profiling Go Programs 分析go语言项目

    Profiling Go Programs  分析go语言项目 24 June 2011 At Scala Days 2011, Robert Hundt presented a paper titl ...

  2. MySQL权限操作:Grant、Revoke

    数据库操作: 创建数据库.创建表——CREATE 删除数据库.删除表——DROP 删除表内容——TRUNCATE.DELETE(后者效率低.一行一行地删除记录) 查询数据库.查询表——SELECT 插 ...

  3. java基础23 Math类和Random类

    一.Math数学类 主要是提供很多数学的公式 1.1.Math类的常用方法 abs(int a):绝对值   ceil(double a):向上取整   floor(double a):向下取整   ...

  4. HDU 2819 Swap(行列式性质+最大匹配)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2819 题目大意:给你一个n*n的01矩阵,问是否可以通过任意交换整行或者整列使得正对角线上都是1. ...

  5. SQLSERVER中的人民币数字转大写的函数实现

    CREATE  FUNCTION [dbo].[f_num_chn] (@num numeric(14,5))RETURNS varchar(100) WITH ENCRYPTIONASBEGIN-- ...

  6. 记录一次webpackJsonp is not defined

    始末: 领导让将最近部署的一部分更改隐藏掉,so,我先不存当前分支内容,创建新分支,在新分支里回滚到上一版本,进行更改操作,一切都么问题,本地vue项目与python项目都运行不报错,但在部署后,报错 ...

  7. Linux学习笔记:ls和ll命令

    list显示当前目录中的文件名字,不加参数时显示除隐藏文件外的所有文件及目录的名字. ll 等同于 ls -l-r 对目录反向排序(按字母)-t 以时间排序-u 以文件上次被访问的时间排序-x 按列输 ...

  8. 在 Python 中使用 GDB 来调试 转载

    2013/11/01 | Comments 大约一年前,我接触了 Java 中的 Btrace 能够不停机查看线上 JVM 运行情况的特性让我艳羡不已. 另外还有强悍的 jStack 和 jConso ...

  9. element-ui 2.7.2版本使用 表格展开行 功能遇到的奇葩问题?

    在使用 element-ui 2.7.2版本的时候报下面的错误: [Vue warn]: Error in callback for watcher "data": "E ...

  10. CentOS 7不能联网解决办法

    在使用 Ubuntu 一段时间之后想体验一下 CentOS,就去下载了 CentOS 7 安装到了虚拟机里面,结果发现不能联网,一直提示Cannot find a valid baseurl for ...