簡體   English   中英

typeerror: __call__() 需要 2 個位置 arguments 但給出了 3 個(Gunicorn)

[英]typeerror: __call__() takes 2 positional arguments but 3 were given (Gunicorn)

我使用 flask 制作了 web 應用程序。 該應用程序在我本地運行時運行良好(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(異步燒瓶),當我搬到 flask 時,一切正常。 所以,問題在於誇脫。

Flask 是一個 WSGI 框架,它與 WSGI 服務器 Gunicorn 配合得很好。 然而,Quart 是一個 ASGI 框架,因此需要一個 ASGI 服務器。 Quart文檔推薦ASGI 服務器 Hypercorn。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM