你试过跑步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"