为什么asyncio的事件循环会抑制Windows上的KeyboardInterrupt? [英] Why does the asyncio's event loop suppress the KeyboardInterrupt on Windows?

查看:137
本文介绍了为什么asyncio的事件循环会抑制Windows上的KeyboardInterrupt?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常小的测试程序,除了执行asyncio事件循环外,什么也没有做:

I have this really small test program which does nothing apart from a executing an asyncio event loop:

import asyncio
asyncio.get_event_loop().run_forever()

当我在Linux上运行该程序并按 Ctrl + C 时,该程序将正确终止,并出现KeyboardInterrupt异常.在Windows上,按 Ctrl + C 不会执行任何操作(已在Python 3.4.2中进行了测试). time.sleep()的简单无限循环即使在Windows上也可以正确地提高KeyboardInterrupt:

When I run this program on Linux and press Ctrl+C, the program will terminate correctly with a KeyboardInterrupt exception. On Windows pressing Ctrl+C does nothing (tested with Python 3.4.2). A simple inifinite loop with time.sleep() raises the KeyboardInterrupt correctly even on Windows:

import time
while True:
    time.sleep(3600)

为什么异步事件循环会抑制Windows上的KeyboardInterrupt?

Why does the asyncio's event loop suppress the KeyboardInterrupt on Windows?

推荐答案

确定是一个错误.

有关解决问题的进展,请参见关于python bug-tracker的问题.

See issue on python bug-tracker for the problem solving progress.

这篇关于为什么asyncio的事件循环会抑制Windows上的KeyboardInterrupt?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆