Python gevent+中抑制的Greenlet异常;龙卷风装置

Python gevent+中抑制的Greenlet异常;龙卷风装置,python,tornado,gevent,Python,Tornado,Gevent,当通过gevent的pywsgi服务器运行tornado的WSGIApplication时,greenlets中的异常将被抑制,并且不会显示在标准错误/输出中。我看了又看,找不到为什么会这样 下面是一个小测试应用程序来演示: #/usr/bin/env python 导入gevent.monkey gevent.monkey.patch_all() 导入gevent.wsgi 导入tornado.web 导入tornado.wsgi 类MainHandler(tornado.web.Reques

当通过gevent的pywsgi服务器运行tornado的WSGIApplication时,greenlets中的异常将被抑制,并且不会显示在标准错误/输出中。我看了又看,找不到为什么会这样

下面是一个小测试应用程序来演示:

#/usr/bin/env python
导入gevent.monkey
gevent.monkey.patch_all()
导入gevent.wsgi
导入tornado.web
导入tornado.wsgi
类MainHandler(tornado.web.RequestHandler):
def准备(自我):
#下一行将导致名称错误
a=我在这里不存在
类应用程序(tornado.wsgi.WSGIApplication):
定义初始化(自):
tornado.wsgi.WSGIApplication.\uuuu init\uuuuu(self,[(r/,MainHandler)])
如果uuuu name uuuuuu='\uuuuuuu main\uuuuuuu':
gevent.wsgi.WSGIServer((“”,80),App()).serve_forever()

您是否尝试过运行
tornado.options.parse_命令行()

输出:

[E 130819 00:11:27 web:1228] Uncaught exception GET / (127.0.0.1)
    <tornado.wsgi.HTTPRequest object at 0x0000000003009A20>
    Traceback (most recent call last):
      File "C:\Python27\lib\site-packages\tornado\web.py", line 1141, in _when_complete
        callback()
      File "C:\Python27\lib\site-packages\tornado\web.py", line 1162, in _execute_method
        self._when_complete(method(*self.path_args, **self.path_kwargs),
      File "Test.py", line 16, in get
        raise Exception("Something terrible happened here")
    Exception: Something terrible happened here
127.0.0.1 - - [2013-08-19 00:11:27] "GET / HTTP/1.1" 500 93 "-" "Mozilla/5.0 (Wi
ndows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0"
[E 130819 00:11:27 web:1228]未捕获的异常获取/(127.0.0.1)
回溯(最近一次呼叫最后一次):
文件“C:\Python27\lib\site packages\tornado\web.py”,第1141行,完成后放入
回调函数()
文件“C:\Python27\lib\site packages\tornado\web.py”,第1162行,在执行方法中
self.\u完成时(方法(*self.path\u args,**self.path\u kwargs),
get中第16行的文件“Test.py”
引发异常(“这里发生了可怕的事情”)
例外:这里发生了可怕的事情
127.0.0.1--[2013-08-19 00:11:27]“GET/HTTP/1.1”50093“-”Mozilla/5.0(Wi
ndows NT 6.1;WOW64;rv:23.0)Gecko/20100101 Firefox/23.0“
[E 130819 00:11:27 web:1228] Uncaught exception GET / (127.0.0.1)
    <tornado.wsgi.HTTPRequest object at 0x0000000003009A20>
    Traceback (most recent call last):
      File "C:\Python27\lib\site-packages\tornado\web.py", line 1141, in _when_complete
        callback()
      File "C:\Python27\lib\site-packages\tornado\web.py", line 1162, in _execute_method
        self._when_complete(method(*self.path_args, **self.path_kwargs),
      File "Test.py", line 16, in get
        raise Exception("Something terrible happened here")
    Exception: Something terrible happened here
127.0.0.1 - - [2013-08-19 00:11:27] "GET / HTTP/1.1" 500 93 "-" "Mozilla/5.0 (Wi
ndows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0"