wordpress   发布时间:2022-04-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了如何在Windows上捕获Python中的SIGINT?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

(与 this question相似) 在Python 2.7下的UNIX上,在Python提示符下: >>> import signal >>> def handler(signal, framE): ... print 'welcome to the handler' ... >>> signal.signal(signal.SIGINT, handler) <built-i
(与 this question相似)

在Python 2.7下的UNIX上,在Python提示符下:

>>> import signal
 >>> def handler(signal,framE):
 ...     print 'welcome to the handler'
 ...
 >>> signal.signal(signal.SIGINT,handler)
 <built-in function default_int_handler>

我按ctrl-c

>>> welcome to the handler

 >>>

在Windows上:

>>> import signal
 >>> def handler(signal,handler)
 <built-in function default_int_handler>

按ctrl-c:

>>>
 KeyboardInterrupt
 >>>

我可以验证处理程序是否正在安装Python端作为SIGINT的处理程序(调用signal.signal第二个计时器返回我的处理程序).如何在Windows上捕获SIGINT?

解决方法

在上游打开 the bug后,找到了问题的根本原因并编写了补丁.这个补丁不会进入python 2.x系列.

大佬总结

以上是大佬教程为你收集整理的如何在Windows上捕获Python中的SIGINT?全部内容,希望文章能够帮你解决如何在Windows上捕获Python中的SIGINT?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。