Python 烧瓶龙卷风控制+;windows中的C端接

Python 烧瓶龙卷风控制+;windows中的C端接,python,windows,python-2.7,flask,tornado,Python,Windows,Python 2.7,Flask,Tornado,以下代码: from tornado.wsgi import WSGIContainer from tornado.httpserver import HTTPServer from tornado.ioloop import IOLoop def start(app, port=8080): http_server = HTTPServer(WSGIContainer(app)) http_server.listen(port) try:

以下代码:

from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop  


def start(app, port=8080):  
      http_server = HTTPServer(WSGIContainer(app))
      http_server.listen(port)
      try:
          IOLoop.instance().start()
      except KeyboardInterrupt:
          print "stop"
          IOLoop.instance().stop()
我想在Windows中使用CTRL+C或CTRL+PauseBreak停止tornado服务器,但在CMD中CTRL+C不能停止

Ctrl+PauseBreak会停止CMD并终止python.exe,但不会显示“停止”


如何在windows中输入键盘中断?

在windows上,
select()
函数(IOLoop内部使用)不可中断()。最简单的解决方法是启动一个
周期回调
(它不需要做任何事情;只需要一个空函数);当回调被触发时,IOLoop将被唤醒,键盘中断异常将被引发