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触发器Trigger实例篇
定义: 何为MySQL触发器? 在MySQL Server里面也就是对某一个表的一定的操作,触发某种条件(Insert,Update,Delete 等),从而自动执行的一段程序.从这种意义上讲触发器是 ...
- python基础--os模块和sys模块
os模块提供对操作系统进行调用的接口 # -*- coding:utf-8 -*-__author__ = 'shisanjun' import os print(os.getcwd())#获取当前工 ...
- Python_oldboy_自动化运维之路_全栈考试(五)
1.执行 Python 脚本的两种方式 [root@localhost tmp]# cat a.py #!/usr/bin/python # -*- coding: UTF-8 -*- print & ...
- luogu P3393 逃离僵尸岛
luoguP3393逃离_僵尸岛_ 一道洛谷不知道哪门子月赛的题 可以用此题来练习最短路算法 SPFA和dijkstra的练习题(关于Floyed,他死了 思路: 本题是最短路板子. 首先就是建立虚点 ...
- es6遍历数组forof
- Python练手之爬虫
很久没更新博客了,最近自学Python,写个在百度上爬算法题题解的爬虫,第一次写爬虫..纯当练手 慢慢来.. #coding:utf-8 ''' Created on 2016年11月22日 @aut ...
- Rewrite HTTP to HTTPS in Nginx
1.推荐配置 server { listen 80; server_name example1.com example2.com; return 301 https://$host$request_u ...
- hmm学习笔记(二)
学习hmm近一周的时间,做个总结. 参考 李航的<统计学习方法>第9章,第10章 本文包含: 1.hmm模型 2.前向后向算法 3.Baum-Welch算法 4.维特比算法 1.hmm模 ...
- oracle配置ODBC
摘自:http://www.cnblogs.com/shelvenn/p/3799849.html 我使用的Windows 10,64位的操作系统. 1.下载驱动包 base包:instantclie ...
- 在windows下使用Cygwin模拟unix环境 并安装apt-cyg svn等插件
在windows下使用Cygwin模拟unix环境,并安装apt-cyg,svn等工具 一.Cygwin的安装 1. 下载Cygwin,这个可以到这里下载 ,至于使用32位的还是64位的版本可以根据自 ...