问题描述
我有一个非常小的测试程序,除了执行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上运行该程序并按 + 时,该程序将正确终止,并出现KeyboardInterrupt
异常.在Windows上,按 + 不会执行任何操作(已在Python 3.4.2中进行了测试). time.sleep()
的简单无限循环即使在Windows上也可以正确地提高KeyboardInterrupt
:
When I run this program on Linux and press +, the program will terminate correctly with a KeyboardInterrupt
exception. On Windows pressing + 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!