How to exit the entire application from a Python thread?
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?的更多相关文章
- 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 ...
- Environment.Exit(0) 、Application.Exit() 、this.Close() 、this.Dispose()的区别
Application.Exit:通知winform消息循环退出.程序会等待所有的前台线程终止后才能真正退出.是一种强行退出方式,就像 Win32 的 PostQuitMessage().它意味着放弃 ...
- 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 ...
- 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 ...
- 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 ...
- 【转】 Android自定义捕获Application全局异常
大家都知道,现在安装Android系统的手机版本和设备千差万别,在模拟器上运行良好的程序安装到某款手机上说不定就出现崩溃的现象,开发者个人不可能购买所有设备逐个调试,所以在程序发布出去之后,如果出现了 ...
- Controlling How NSThread and NSRunLoop Exit
http://shaheengandhi.com/controlling-thread-exit/ While most concurrency can be dealt with by using ...
- Android Application Fundamentals——Android应用程序基础知识
Application Fundamentals--应用程序基础知识 Key classes--关键类 Activity Service BroadcastReceiver ContentProvid ...
- 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 ...
随机推荐
- 数据库--mysql介绍
一:什么是数据库 数据库(Database)是按照数据结构来组织.存储和管理数据的仓库, 每个数据库都有一个或多个不同的API用于创建,访问,管理,搜索和复制所保存的数据. 我们也可以将数据存储在文件 ...
- ASP .Net Core系统部署到Ubuntu 16.04 具体方案
.Net Core 部署到Ubuntu 16.04 中的步骤 1.安装工具 1.apache 2..Net Core(dotnet-sdk-2.0) 3.Supervisor(进程管理工具,目的是服务 ...
- Gitflow工作流
什么是Gitflow工作流 Gitflow工作流定义了一个围绕项目发布的严格分支模型.虽然比功能分支工作流复杂几分,但提供了用于一个健壮的用于管理大型项目的框架. Gitflow工作流没有用超出功能分 ...
- poj 2369(置换群)
Permutations Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3041 Accepted: 1641 Desc ...
- 15 链表中倒数第k个结点
输入一个链表,输出该链表中倒数第k个结点. p1先走k-1步,p1 p2再一起走 C++: /* struct ListNode { int val; struct ListNode *next; L ...
- Spark(十一)Spark分区
一.分区的概念 分区是RDD内部并行计算的一个计算单元,RDD的数据集在逻辑上被划分为多个分片,每一个分片称为分区,分区的格式决定了并行计算的粒度,而每个分区的数值计算都是在一个任务中进行的,因此任务 ...
- 【社区公益】送《Web前端开发最佳实践》给需要的人
算起来至今,我进入软件开发行业已经有11年之久.从最初的研究人工智能,到后来的Web开发,控件开发,直到现在纯粹的Web前端开发.虽然没有大的作品问世,但也是勤勤恳恳,踏实做事,低调做人.从来不吹牛逼 ...
- 【UOJ】#37. 【清华集训2014】主旋律
题解 一道,神奇的题= = 我们考虑正难则反,我们求去掉这些边后有多少图不是强连通的 怎么求呢,不是强连通的图缩点后一定是一个DAG,并且这个DAG里面有两个点 我们想一下,如果我们把1当成入度为0的 ...
- centos7+python3.6+nginx+uwsgi+django2的搭建笔记
公司需上线一套python编写的代码,需要给搭建一套环境 ,本次采用centos7+python3.6+nginx+uwsgi2+django2+mysql5.7的方式来进行搭建 写在部署前 在线上 ...
- Ionic实战九:ionic视频播放
本模板和以前的方式不同,采用的是 iframe方式引入的视频,如下代码: