جونيكورن + فاستابي
from fastapi import FastAPI
app = FastAPI()
@app.post("/tet")
async def root():
return {"message": "Hello World"}
""
gunicorn -k gevent - ربط "0.0.0.0:8080" - تصحيح أخطاء مستوى السجل الرئيسي: التطبيق
```
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'
يعمل FastAPI فقط في خادم ASGI. لا يشحن gunicorn إلا مع تطبيقات معيار PEP 3333 WSGI. الاثنان غير متوافقين.
تضمين التغريدة
شكرًا ، هل هذا يعني أن فئة العمال من gunicorn يجب أن تكون "uvicorn.workers.UvicornWorker"؟
مثل
gunicorn -k uvicorn.workers.UvicornWorker --bind "0.0.0.0:8080" --log-level debug main:app
هل هناك اي طرق اخرى؟
على حد علمي ، هذا هو العامل الوحيد الذي يطبق ASGI بدلاً من WSGI.
حسنا شكرا كثيرا!
التعليق الأكثر فائدة
تضمين التغريدة
شكرًا ، هل هذا يعني أن فئة العمال من gunicorn يجب أن تكون "uvicorn.workers.UvicornWorker"؟
مثل
هل هناك اي طرق اخرى؟