Is it OK to have a 10-30 second coroutines in FastAPI?
(in the terms of FastApi performance and good practices)
So the client will have a request-response open for 10-30 seconds.
On the client side we are using React.js, so it's fine for them.
@app.get("/somepath")
async def read_item():
async with aiohttp.ClientSession() as session:
# some slow external API, 10-30 seconds
async with session.get(f"https://external.website.com/{some_api_key}/") as response:
response_json = await response.json()
return response_json