I'm probably not understanding the asynchronous concept correctly in FastAPI.
I'm accessing the root endpoint of the following app from two clients at the same time. I'd expect FastAPI to print Started
twice in a row at the start of the execution:
from fastapi import FastAPI
import asyncio
app = FastAPI()
@app.get("/")
async def read_root():
print('Started')
await asyncio.sleep(5)
print('Finished')
return {"Hello": "World"}
Instead I get the following, which looks very much non asynchronous:
Started
Finished
INFO: ('127.0.0.1', 49655) - "GET / HTTP/1.1" 200
Started
Finished
INFO: ('127.0.0.1', 49655) - "GET / HTTP/1.1" 200
What am I missing?