How to fix "TypeError: __call__() takes 2 positional arguments but 3 were given" in tornado.wsgi?
How to fix "TypeError: __call__() takes 2 positional arguments but 3 were given" in tornado.wsgi?
我正在尝试使用 wsgi 形式的龙卷风,因为服务器只接受 wsgi。
我已经尝试了 tornado + wsgi 的所有服务器变体,总是收到此错误:__call__() takes 2 positional arguments but 3 were given
# app/__init__.py
import tornado.wsgi
import tornado.web
import wsgiref.simple_server
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.render("templates/index.html")
def routes():
return [
(r"/", MainHandler),
]
class Application(tornado.wsgi.WSGIContainer):
def __init__(self):
handlers = routes()
tornado.wsgi.WSGIContainer.__init__(self, handlers)
# wsgi.py
import wsgiref.simple_server
from app import Application
application = Application()
server = wsgiref.simple_server.make_server('', 8888, Application())
server.serve_forever()
这是错误跟踪:
Traceback (most recent call last):
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/wsgiref/handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
TypeError: __call__() takes 2 positional arguments but 3 were given
127.0.0.1 - - [10/Aug/2019 17:40:58] "GET / HTTP/1.1" 500 59
我期待工作 tornado.wsgi,任何帮助都会有用!
WSGIContainer
走向另一个方向:它让你 运行 在 Tornado 的 HTTP 服务器上的 wsgi 应用程序,而不是 运行 在 WSGI 服务器上的 tornado 应用程序。
在 Tornado 5.1 中,您可以使用 WSGIAdapter 执行此操作。在 Tornado 6.0 中,WSGIAdapter
消失了,不再有任何方法可以在 WSGI 服务器上 运行 Tornado 应用程序;你必须使用 Tornado 的服务器。
我正在尝试使用 wsgi 形式的龙卷风,因为服务器只接受 wsgi。
我已经尝试了 tornado + wsgi 的所有服务器变体,总是收到此错误:__call__() takes 2 positional arguments but 3 were given
# app/__init__.py
import tornado.wsgi
import tornado.web
import wsgiref.simple_server
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.render("templates/index.html")
def routes():
return [
(r"/", MainHandler),
]
class Application(tornado.wsgi.WSGIContainer):
def __init__(self):
handlers = routes()
tornado.wsgi.WSGIContainer.__init__(self, handlers)
# wsgi.py
import wsgiref.simple_server
from app import Application
application = Application()
server = wsgiref.simple_server.make_server('', 8888, Application())
server.serve_forever()
这是错误跟踪:
Traceback (most recent call last):
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/wsgiref/handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
TypeError: __call__() takes 2 positional arguments but 3 were given
127.0.0.1 - - [10/Aug/2019 17:40:58] "GET / HTTP/1.1" 500 59
我期待工作 tornado.wsgi,任何帮助都会有用!
WSGIContainer
走向另一个方向:它让你 运行 在 Tornado 的 HTTP 服务器上的 wsgi 应用程序,而不是 运行 在 WSGI 服务器上的 tornado 应用程序。
在 Tornado 5.1 中,您可以使用 WSGIAdapter 执行此操作。在 Tornado 6.0 中,WSGIAdapter
消失了,不再有任何方法可以在 WSGI 服务器上 运行 Tornado 应用程序;你必须使用 Tornado 的服务器。