Fastapi führt API -Aufrufe in seriell anstelle paralleler Weise aus
Posted: 19 May 2025, 06:56
Ich habe die folgende Fastapi-Anwendung: < /p>
Aufrufen des obigen Endpunkts auf Localhost - E.g.
Ich habe über die Verwendung von httpx gelesen, aber trotzdem kann ich keine echte Parallelisierung erhalten. Was ist das Problem?
Code: Select all
from fastapi import FastAPI, Request
import time
app = FastAPI()
@app.get("/ping")
async def ping(request: Request):
print("Hello")
time.sleep(5)
print("bye")
return {"ping": "pong!"}
Code: Select all
Hello
bye
Hello
bye
< /code>
statt: < /p>
Hello
Hello
bye
bye