【问题标题】:typeerror: __call__() takes 2 positional arguments but 3 were given (Gunicorn)typeerror: __call__() 接受 2 个位置参数,但给出了 3 个(Gunicorn)
【发布时间】:2021-03-28 15:46:21
【问题描述】:

我使用烧瓶制作了一个网络应用程序。该应用程序在我本地运行时运行良好(Gunicorn 根本不涉及)但是当我在 Heroku 上部署该应用程序时,它会在控制台中引发以下 TypeError。

2021-03-28T15:42:25.446327+00:00 app[web.1]: Traceback (most recent call last):
2021-03-28T15:42:25.446329+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 136, in handle
2021-03-28T15:42:25.446329+00:00 app[web.1]:     self.handle_request(listener, req, client, addr)
2021-03-28T15:42:25.446336+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 179, in handle_request
2021-03-28T15:42:25.446337+00:00 app[web.1]:     respiter = self.wsgi(environ, resp.start_response)
2021-03-28T15:42:25.446345+00:00 app[web.1]: TypeError: __call__() takes 2 positional arguments but 3 were given

我的 procfile 是这样的:

web: gunicorn app:app

Gunicorn 也已正确安装。

我尝试过的事情:

  • 也尝试设置 procfile:web: gunicorn -w 4 -k uvicorn.workers.UvicornWorker app:app(没用)

  • 编辑:我将 python 运行时更新为python-3.8.6,这导致了另一个错误:

2021-03-28T15:49:20.246747+00:00 app[web.1]: Traceback (most recent call last):
2021-03-28T15:49:20.246748+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/workers/sync.py", line 136, in handle
2021-03-28T15:49:20.246749+00:00 app[web.1]:     self.handle_request(listener, req, client, addr)
2021-03-28T15:49:20.246756+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/workers/sync.py", line 179, in handle_request
2021-03-28T15:49:20.246757+00:00 app[web.1]:     respiter = self.wsgi(environ, resp.start_response)
2021-03-28T15:49:20.246758+00:00 app[web.1]: TypeError: __call__() missing 1 required positional argument: 'send'
  • 编辑 2:我使用的是 Quart(异步烧瓶),当我移至烧瓶时,一切正常。所以,问题出在 Quart 上。

【问题讨论】:

    标签: python heroku gunicorn


    【解决方案1】:

    Flask 是一个 WSGI 框架,可以很好地与 Gunicorn(一个 WSGI 服务器)配合使用。然而,Quart 是一个 ASGI 框架,因此需要一个 ASGI 服务器。 Quart docs recommend ASGI 服务器 Hypercorn。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-02-02
      • 2020-03-27
      • 2022-01-19
      • 2017-02-18
      • 2021-01-22
      • 2020-05-23
      • 2020-01-06
      • 2019-04-29
      相关资源
      最近更新 更多