Gunicorn: TypeError: __call__() ๋ˆ„๋ฝ๋œ 1๊ฐœ์˜ ํ•„์ˆ˜ ์œ„์น˜ ์ธ์ˆ˜: '๋ณด๋‚ด๊ธฐ'

์— ๋งŒ๋“  2019๋…„ 11์›” 08์ผ  ยท  4์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: benoitc/gunicorn

๊ท€๋‹ˆ์ฝ˜ + ํŒจ์ŠคํŠธํ”ผ

ํŒจ์ŠคํŠธํ”ผ:

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

์ด๊ฐ:

```
gunicorn -k gevent --bind "0.0.0.0:8080" --log-level ๋””๋ฒ„๊ทธ ๋ฉ”์ธ:์•ฑ

 ```
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์€ PEP 3333 WSGI ํ‘œ์ค€ ๊ตฌํ˜„๊ณผ ํ•จ๊ป˜ ์ œ๊ณต๋ฉ๋‹ˆ๋‹ค. ๋‘˜์€ ํ˜ธํ™˜๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

@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 ๋“ฑ๊ธ‰