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

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

Post 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?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post