我正在尝试使用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,任何帮助将是有用的!
发布于 2019-08-10 17:42:10
WSGIContainer
则相反:它允许你在tornado的HTTP服务器上运行wsgi应用程序,而不是在WSGI服务器上运行tornado应用程序。
在Tornado5.1中,你可以用WSGIAdapter做到这一点。在Tornado6.0中,WSGIAdapter
消失了,不再有任何方法可以在WSGI服务器上运行Tornado应用程序;您必须使用Tornado的服务器。
https://stackoverflow.com/questions/57443566
复制