2013-08-16 2 views
1

gevent의 pywsgi 서버를 통해 토네이도의 WSGIApplication을 실행하면 greenlets의 예외가 표시되지 않고 표준 오류/출력에 표시되지 않습니다. 나는 보았고, 보았고, 이것이 일어나고있는 이유를 발견 할 수 없었다.gevent + torornado 설정에서 Greenlet 예외가 표시되지 않음

여기에 약간의 테스트 애플 리케이션은 보여입니다 :

#!/usr/bin/env python 

import gevent.monkey 
gevent.monkey.patch_all() 

import gevent.wsgi 
import tornado.web 
import tornado.wsgi 

class MainHandler(tornado.web.RequestHandler): 
    def prepare(self): 
    # this next line will cause a NameError 
    a = i_dont_exist_here 

class App(tornado.wsgi.WSGIApplication): 
    def __init__(self): 
    tornado.wsgi.WSGIApplication.__init__(self, [(r"/", MainHandler)]) 

if __name__ == '__main__': 
    gevent.wsgi.WSGIServer(('', 80), App()).serve_forever() 

답변

0

tornado.options.parse_command_line()을 실행하려고 했습니까?

#!/usr/bin/env python 
# -*- coding: utf-8 -*- 

import gevent.monkey 
gevent.monkey.patch_all() 

import gevent.wsgi 
import tornado.web 
import tornado.wsgi 

from tornado.options import parse_command_line 
tornado.options.parse_command_line() 

class MainHandler(tornado.web.RequestHandler): 
    def get(self): 
     raise Exception("Something terrible happened here") 

class App(tornado.wsgi.WSGIApplication): 
    def __init__(self): 
     tornado.wsgi.WSGIApplication.__init__(self, [(r"/", MainHandler)]) 

if __name__ == '__main__': 
    gevent.wsgi.WSGIServer(('', 8000), App()).serve_forever() 

출력 :

[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"