【发布时间】:2014-12-15 09:32:42
【问题描述】:
我有一个非常小的测试程序,除了执行asyncio 事件循环之外什么都不做:
import asyncio
asyncio.get_event_loop().run_forever()
当我在 Linux 上运行此程序并按 Ctrl+C 时,程序将正确终止并出现 KeyboardInterrupt 异常。在 Windows 上按 Ctrl+C 什么都不做(用 Python 3.4.2 测试)。即使在 Windows 上,带有 time.sleep() 的简单无限循环也会正确引发 KeyboardInterrupt:
import time
while True:
time.sleep(3600)
为什么 asyncio 的事件循环会抑制 Windows 上的 KeyboardInterrupt?
【问题讨论】:
标签: python windows python-3.4 python-asyncio keyboardinterrupt