首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >如何修复tornado.wsgi中的"TypeError:__call__()接受2个位置参数但给出了3个“?

如何修复tornado.wsgi中的"TypeError:__call__()接受2个位置参数但给出了3个“?
EN

Stack Overflow用户
提问于 2019-08-10 23:47:29
回答 1查看 1.1K关注 0票数 2

我正在尝试使用wsgi形式的龙卷风,因为服务器只接受wsgi。

我尝试了tornado + wsgi的所有服务器变体,总是得到这样的错误:__call__() takes 2 positional arguments but 3 were given

代码语言:javascript
代码运行次数:0
运行
复制
# 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)
代码语言:javascript
代码运行次数:0
运行
复制
# wsgi.py 

import wsgiref.simple_server
from app import Application

application = Application()
server = wsgiref.simple_server.make_server('', 8888, Application())
server.serve_forever()

以下是错误跟踪:

代码语言:javascript
代码运行次数:0
运行
复制
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,任何帮助将是有用的!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-08-11 01:42:10

WSGIContainer则相反:它允许你在tornado的HTTP服务器上运行wsgi应用程序,而不是在WSGI服务器上运行tornado应用程序。

在Tornado5.1中,你可以用WSGIAdapter做到这一点。在Tornado6.0中,WSGIAdapter消失了,不再有任何方法可以在WSGI服务器上运行Tornado应用程序;您必须使用Tornado的服务器。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57443566

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档