标签:__ gunicorn -- 0.0 app 报错 workers
使用 gunicorn -w 4 -b 0.0.0.0:8080 main:app
运行时,报错 TypeError: __call__() missing 1 required positional argument: 'send'
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 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
[2020-06-08 16:05:42 +0800] [12796] [DEBUG] 1 workers
[2020-06-08 16:05:49 +0800] [12799] [DEBUG] GET /tet
[2020-06-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'
原因:
FastAPI only runs in an ASGI server. gunicorn only ships with implementations of the PEP 3333 WSGI standard. The two are not compatible.
FastAPI 仅在 ASGI 服务器中运行。gunicorn 仅附带 PEP 3333 WSGI 标准的实现。两者不兼容。
需要指定 uvicorn.workers.UvicornH11Worker
gunicorn -k uvicorn.workers.UvicornWorker --bind "0.0.0.0:8080" --log-level debug main:app
标签:__,gunicorn,--,0.0,app,报错,workers 来源: https://www.cnblogs.com/darling331/p/16371877.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。