python - tornado.wsgi.WSGIApplication issue: __call__ takes exactly 3 arguments (2 given) -


as part of project, i've been trying port tornado server work on google app engine. since app engine doesn't implement asynchronous functions of normal tornado, i've been trying convert main application wsgiapplication. normal main code works fine (forgive imports , formatting, it's mess trying follow other examples):

import wsgiref import tornado.wsgi import tornado.web import tornado.httpserver import os import handlers tornado.options import define, options  define("port", default=8000, help="run on 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.web.application(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() 

i can access web pages, browse site, works great. if change line 24 return tornado.wsgi.wsgiapplication, thus:

import wsgiref import tornado.wsgi import tornado.web import tornado.httpserver import os import handlers tornado.options import define, options  define("port", default=8000, help="run on 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() 

it runs fine. however, when try access of web pages, gives me following error:

[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 3 arguments (2 given) [e 140131 10:02:18 ioloop:491] exception in callback <functools.partial object @ 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 3 arguments (2 given) 

which can't make heads or tails of, , google hasn't turned same problem (except guy recommended mucking around in tornado files, won't on app engine afaik). has else seen error before, or can spot why wsgiapplication crashes when default application not?

the name "application" unfortunately overloaded here - tornado.web.application , wsgiapplication differ in interface server. tornado.web.application can used tornado httpserver, wsgiapplication must run in wsgi container. in app engine deployment, you'd mention wsgiapplication instance directly in config file, no mention of tornado.httpserver. use adapt wsgiapplication tornado.httpserver, use tornado.wsgi.wsgicontainer: httpserver(wsgicontainer(application()))


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -