Gunicorn: TypeError:__call __()1つの必須の位置引数がありません:'send'

作成日 2019年11月08日  ·  4コメント  ·  ソース: benoitc/gunicorn

gunicorn + fastapi

fastapi:

from fastapi import FastAPI
app = FastAPI()
@app.post("/tet")
async def root():
    return {"message": "Hello World"}

gunicorn:

`` `
gunicorn -k gevent --bind "0.0.0.0:8080" --log-level debug main:app

 ```
gunicorn -k tornado --bind "0.0.0.0:8080" --log-level debug main:app

エラー:

email-validator not installed, email fields will be treated as str.
To install, run: pip install email-validator
[2019-11-08 16:05:42 +0800] [12796] [DEBUG] 1 workers
[2019-11-08 16:05:49 +0800] [12799] [DEBUG] GET /tet
[2019-11-08 16:05:49 +0800] [12799] [ERROR] Error handling request /tet
Traceback (most recent call last):
  File "/home/ap/nlp/Anaconda3/lib/python3.6/site-packages/gunicorn/workers/base_async.py", line 56, in handle
    self.handle_request(listener_name, req, client, addr)
  File "/home/ap/nlp/Anaconda3/lib/python3.6/site-packages/gunicorn/workers/ggevent.py", line 160, in handle_request
    addr)
  File "/home/ap/nlp/Anaconda3/lib/python3.6/site-packages/gunicorn/workers/base_async.py", line 107, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
TypeError: __call__() missing 1 required positional argument: 'send'

最も参考になるコメント

@jamadden
ありがとう、それはgunicornのworker_classが'uvicorn.workers.UvicornWorker'でなければならないという意味ですか?
お気に入り

gunicorn -k uvicorn.workers.UvicornWorker --bind "0.0.0.0:8080" --log-level debug main:app

他に方法はありますか?

全てのコメント4件

FastAPIはASGIサーバーでのみ実行されます。 gunicornには、PEP3333WSGI標準の実装のみが付属しています。 2つは互換性がありません。

@jamadden
ありがとう、それはgunicornのworker_classが'uvicorn.workers.UvicornWorker'でなければならないという意味ですか?
お気に入り

gunicorn -k uvicorn.workers.UvicornWorker --bind "0.0.0.0:8080" --log-level debug main:app

他に方法はありますか?

私の知る限り、WSGIの代わりにASGIを実装しているのはそれだけです。

はい、ありがとございます!

このページは役に立ちましたか?
0 / 5 - 0 評価