Python tornado.wsgi.WSGIApplication问题:_调用__恰好接受3个参数(给定2个)

Python tornado.wsgi.WSGIApplication问题:_调用__恰好接受3个参数(给定2个),python,google-app-engine,tornado,wsgi,Python,Google App Engine,Tornado,Wsgi,作为一个项目的一部分,我一直在尝试移植一个Tornado服务器,以便在Google应用程序引擎上工作。由于应用程序引擎没有实现普通Tornado的异步功能,我一直在尝试将主应用程序转换为WSGIApplication。正常的主代码工作正常(请原谅导入和格式化,尝试遵循其他示例会造成混乱): 我可以访问网页,浏览网站,效果很好。如果我将第24行更改为返回tornado.wsgi.WSGIApplication,如下所示: import wsgiref import tornado.wsgi imp

作为一个项目的一部分,我一直在尝试移植一个Tornado服务器,以便在Google应用程序引擎上工作。由于应用程序引擎没有实现普通Tornado的异步功能,我一直在尝试将主应用程序转换为WSGIApplication。正常的主代码工作正常(请原谅导入和格式化,尝试遵循其他示例会造成混乱):

我可以访问网页,浏览网站,效果很好。如果我将第24行更改为返回tornado.wsgi.WSGIApplication,如下所示:

import wsgiref
import tornado.wsgi
import tornado.web
import tornado.httpserver
import os
import Handlers
from tornado.options import define, options

define("port", default=8000, help="run on the given port", type=int)

def application():
    handlers=[(r"/", Handlers.MainHandler),
            (r"/Login", Handlers.LoginHandler),
            (r"/ViewHistory",Handlers.ViewHistoryHandler),
            (r"/UploadFile", Handlers.UploadHandler),
            (r"/Index", Handlers.IndexHandler),
            (r"/About", Handlers.AboutHandler),
            (r"/Profile", Handlers.ProfileHandler)]

    settings=dict(template_path=os.path.join(os.path.dirname(__file__), "templates"),
                static_path=os.path.join(os.path.dirname(__file__), "static"),
                debug=True)

    return tornado.wsgi.WSGIApplication(handlers, **settings)

def main():
    tornado.options.parse_command_line()
    http_server = tornado.httpserver.HTTPServer(application())
    http_server.listen(options.port)
    tornado.ioloop.IOLoop.instance().start()

if __name__ == "__main__":
    main()
它也运行得很好。但是,当我尝试访问任何网页时,会出现以下错误:

[E 140131 10:02:18 iostream:357] Uncaught exception, closing connection.
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/iostream.py", line 354, in wrapper
        callback(*args)
      File "/usr/local/lib/python2.7/dist-packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/stack_context.py", line 331, in wrapped
        raise_exc_info(exc)
      File "/usr/local/lib/python2.7/dist-packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/stack_context.py", line 302, in wrapped
        ret = fn(*args, **kwargs)
      File "/usr/local/lib/python2.7/dist-packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/httpserver.py", line 328, in _on_headers
        self.request_callback(self._request)
    TypeError: __call__() takes exactly 3 arguments (2 given)
[E 140131 10:02:18 ioloop:491] Exception in callback <functools.partial object at 0xf6e3ecfc>
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/ioloop.py", line 477, in _run_callback
        callback()
      File "/usr/local/lib/python2.7/dist-packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/stack_context.py", line 331, in wrapped
        raise_exc_info(exc)
      File "/usr/local/lib/python2.7/dist-packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/stack_context.py", line 302, in wrapped
        ret = fn(*args, **kwargs)
      File "/usr/local/lib/python2.7/dist-packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/iostream.py", line 354, in wrapper
        callback(*args)
      File "/usr/local/lib/python2.7/dist-packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/stack_context.py", line 331, in wrapped
        raise_exc_info(exc)
      File "/usr/local/lib/python2.7/dist-packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/stack_context.py", line 302, in wrapped
        ret = fn(*args, **kwargs)
      File "/usr/local/lib/python2.7/dist-packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/httpserver.py", line 328, in _on_headers
        self.request_callback(self._request)
    TypeError: __call__() takes exactly 3 arguments (2 given)
[E 140131 10:02:18 iostream:357]未捕获异常,正在关闭连接。
回溯(最近一次呼叫最后一次):
文件“/usr/local/lib/python2.7/dist packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/iostream.py”,第354行,在包装器中
回调(*args)
文件“/usr/local/lib/python2.7/dist packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/stack_context.py”,第331行,包装
提升exc信息(exc)
文件“/usr/local/lib/python2.7/dist packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/stack_context.py”,第302行,已包装
ret=fn(*args,**kwargs)
文件“/usr/local/lib/python2.7/dist packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/httpserver.py”,第328行,在标题中
self.request\u回调(self.request)
TypeError:\uuuuu call\uuuuuuu()正好接受3个参数(给定2个)
[E 140131 10:02:18 ioloop:491]回调中出现异常
回溯(最近一次呼叫最后一次):
文件“/usr/local/lib/python2.7/dist packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/ioloop.py”,第477行,在运行回调中
回调函数()
文件“/usr/local/lib/python2.7/dist packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/stack_context.py”,第331行,包装
提升exc信息(exc)
文件“/usr/local/lib/python2.7/dist packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/stack_context.py”,第302行,已包装
ret=fn(*args,**kwargs)
文件“/usr/local/lib/python2.7/dist packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/iostream.py”,第354行,在包装器中
回调(*args)
文件“/usr/local/lib/python2.7/dist packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/stack_context.py”,第331行,包装
提升exc信息(exc)
文件“/usr/local/lib/python2.7/dist packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/stack_context.py”,第302行,已包装
ret=fn(*args,**kwargs)
文件“/usr/local/lib/python2.7/dist packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/httpserver.py”,第328行,在标题中
self.request\u回调(self.request)
TypeError:\uuuuu call\uuuuuuu()正好接受3个参数(给定2个)
我对此一无所知,谷歌也没有发现任何人有同样的问题(除了那个建议在Tornado文件中捣乱的家伙,这对应用程序引擎AFAIK没有帮助)。以前是否有其他人见过此错误,或者可以发现当默认应用程序没有崩溃时WSGIApplication崩溃的原因?

这里的名称“Application”不幸超载-tornado.web.Application和WSGIApplication与服务器的接口不同。tornado.web.Application可由tornado HTTPServer使用,但WSGIApplication必须在WSGI容器中运行。在应用程序引擎部署中,您只需在配置文件中直接提到您的WSGIApplication实例,而不必提及tornado.httpserver。要将wsgi应用程序适配到tornado.httpserver,请使用tornado.wsgi.WSGIContainer:
httpserver(WSGIContainer(application())

[E 140131 10:02:18 iostream:357] Uncaught exception, closing connection.
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/iostream.py", line 354, in wrapper
        callback(*args)
      File "/usr/local/lib/python2.7/dist-packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/stack_context.py", line 331, in wrapped
        raise_exc_info(exc)
      File "/usr/local/lib/python2.7/dist-packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/stack_context.py", line 302, in wrapped
        ret = fn(*args, **kwargs)
      File "/usr/local/lib/python2.7/dist-packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/httpserver.py", line 328, in _on_headers
        self.request_callback(self._request)
    TypeError: __call__() takes exactly 3 arguments (2 given)
[E 140131 10:02:18 ioloop:491] Exception in callback <functools.partial object at 0xf6e3ecfc>
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/ioloop.py", line 477, in _run_callback
        callback()
      File "/usr/local/lib/python2.7/dist-packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/stack_context.py", line 331, in wrapped
        raise_exc_info(exc)
      File "/usr/local/lib/python2.7/dist-packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/stack_context.py", line 302, in wrapped
        ret = fn(*args, **kwargs)
      File "/usr/local/lib/python2.7/dist-packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/iostream.py", line 354, in wrapper
        callback(*args)
      File "/usr/local/lib/python2.7/dist-packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/stack_context.py", line 331, in wrapped
        raise_exc_info(exc)
      File "/usr/local/lib/python2.7/dist-packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/stack_context.py", line 302, in wrapped
        ret = fn(*args, **kwargs)
      File "/usr/local/lib/python2.7/dist-packages/tornado-3.2-py2.7-linux-x86_64.egg/tornado/httpserver.py", line 328, in _on_headers
        self.request_callback(self._request)
    TypeError: __call__() takes exactly 3 arguments (2 given)