Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14360

FastAPI runs api-calls in serial instead of parallel fashion

$
0
0

I have the following code:

import timefrom fastapi import FastAPI, Requestapp = FastAPI()@app.get("/ping")async def ping(request: Request):        print("Hello")        time.sleep(5)        print("bye")        return {"ping": "pong!"}

If I run my code on localhost - e.g., http://localhost:8501/ping - in different tabs of the same browser window, I get:

HellobyeHellobye

instead of:

HelloHellobyebye

I have read about using httpx, but still, I cannot have a true parallelization. What's the problem?


Viewing all articles
Browse latest Browse all 14360

Trending Articles