Page 1 of 1

Fastapi führt API -Aufrufe in seriell anstelle paralleler Weise aus

Posted: 19 May 2025, 06:56
by Anonymous
Ich habe die folgende Fastapi-Anwendung: < /p>

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!"}
Aufrufen des obigen Endpunkts auf Localhost - E.g.

Code: Select all

Hello
bye
Hello
bye
< /code>
statt: < /p>
Hello
Hello
bye
bye
Ich habe über die Verwendung von httpx gelesen, aber trotzdem kann ich keine echte Parallelisierung erhalten. Was ist das Problem?