这是错误日志:
[I 160308 11:09:59 web:1908] 200 GET / admin / realtime(117.93.180.216)107.13ms [E 160308 11:09:59 http1connection:54]未捕获的异常 Traceback(最近一次调用最后一次): 文件" /usr/local/lib/python3.4/dist-packages/tornado/http1connection.py" ;,第238行,在_read_message中 delegate.finish() 文件" /usr/local/lib/python3.4/dist-packages/tornado/httpserver.py" ;,第290行,完成 self.delegate.finish() 文件" /usr/local/lib/python3.4/dist-packages/tornado/web.py" ;, 1984年,完成 self.execute() 文件" /usr/local/lib/python3.4/dist-packages/blueware-1.0.10/blueware/hooks/framework_tornado/web.py",第480行,_bw_wrapper__RequestDispatcher_execute future = wrapped(* args,** kwargs) 文件" /usr/local/lib/python3.4/dist-packages/tornado/web.py" ;,第2004行,执行 ** self.handler_kwargs) 文件" /usr/local/lib/python3.4/dist-packages/blueware-1.0.10/blueware/hooks/framework_tornado/web.py",第448行,在_bw_wrapper_RequestHandler___init___中 返回包裹(* args,** kwargs) 文件" /usr/local/lib/python3.4/dist-packages/tornado/web.py" ;,第185行, init self.initialize(** kwargs) 文件" /usr/local/lib/python3.4/dist-packages/tornado/web.py" ;,第2714行,在包装器中 self.redirect(URL) 文件" /usr/local/lib/python3.4/dist-packages/tornado/web.py",第671行,重定向 self.finish() 文件" /usr/local/lib/python3.4/dist-packages/blueware-1.0.10/blueware/hooks/framework_tornado/web.py" ;,第309行,在_bw_wrapper_RequestHandler_finish_中 返回包裹(* args,** kwargs) 文件" /usr/local/lib/python3.4/dist-packages/tornado/web.py" ;,第934行,完成 self.flush(include_footers =真) 文件" /usr/local/lib/python3.4/dist-packages/tornado/web.py" ;,第870行,同花顺 for self._transforms中的变换: TypeError:' NoneType'对象不可迭代 [I 160308 11:10:00 web:1908] 200 GET / admin / order?order_type = 1& order_status = 1& page = 0& action = allreal(49.89.27.173)134.53ms
谁能告诉我如何解决这个问题?非常感谢你
答案 0 :(得分:2)
我认为OneAPM(蓝色代理)与你的python和Tornado版本兼容,但它可能很棘手。
将self.redirect(url)
从您的处理程序initialize
方法移至get
方法,就像这样
class MyHandler(tornado.web.RequestHandler):
def get(self):
self.redirect('/some_url')
或使用RedirectHandler。
每个可以完成请求的操作都需要在http-verb方法(get,post,put等)的上下文中调用。 common mistake正在__init__
或initialize
进行认证/授权。
在Tornado的源代码中,有一条关于_transforms
的注释,该注释在None
的构造函数中初始化,并在_execute
中设置(过度简化 - 在headers_received之后)。
变换修改HTTP请求的结果(例如,GZip编码)。
应用程序不会创建自己的OutputTransforms 或直接与他们互动;框架选择哪个转换 (如果有的话)申请。
触发此错误的示例。我只是将其作为交叉检查,包括蓝色软件不是原因:
import tornado.ioloop
import tornado.web
class SomeHandler(tornado.web.RequestHandler):
def initialize(self, *args, **kwargs):
url = '/some'
self.redirect(url)
# ^ this is wrong
def get(self):
# redirect should be here
self.write("Hello")
def make_app():
return tornado.web.Application([
(r"/", SomeHandler),
])
if __name__ == "__main__":
app = make_app()
app.listen(8888)
tornado.ioloop.IOLoop.current().start()
和stacktrace:
ERROR:tornado.application:Uncaught exception
Traceback (most recent call last):
File "/tmp/py3/lib/python3.4/site-packages/tornado/http1connection.py", line 238, in _read_message
delegate.finish()
File "/tmp/py3/lib/python3.4/site-packages/tornado/httpserver.py", line 289, in finish
self.delegate.finish()
File "/tmp/py3/lib/python3.4/site-packages/tornado/web.py", line 2022, in finish
self.execute()
File "/tmp/py3/lib/python3.4/site-packages/tornado/web.py", line 2042, in execute
**self.handler_kwargs)
File "/tmp/py3/lib/python3.4/site-packages/tornado/web.py", line 183, in __init__
self.initialize(**kwargs)
File "test.py", line 8, in initialize
self.redirect(url)
File "/tmp/py3/lib/python3.4/site-packages/tornado/web.py", line 666, in redirect
self.finish()
File "/tmp/py3/lib/python3.4/site-packages/tornado/web.py", line 932, in finish
self.flush(include_footers=True)
File "/tmp/py3/lib/python3.4/site-packages/tornado/web.py", line 868, in flush
for transform in self._transforms:
TypeError: 'NoneType' object is not iterable