Menu

1 / 9

The path to AI FDE #04: Many calls at once, and a FastAPI service you can lean on

DEV Community: fastapi·Dhanush Kumar Sivaji·4 days ago
#UAfWZFlQ
#devtofastapi#devto#dev#fastapi#async
Reading 0:00
15s threshold

Originally published on my newsletter, The Path to AI FDE. Subscribe free to get each issue by email.

Issue #03 ended with tasks: the way async work actually overlaps. Real AI backends fan out, calling a model several times or fetching a few sources in parallel. So this issue starts with how to do that without losing errors or hanging forever. Then it turns to the FastAPI features that move an endpoint past hello-world. As always, every example is a toy one (a notes app), not my roadmap exercises.

Part A · Many calls at once

1. gather returns results in the order you asked. a, b = await asyncio.gather(fetch(1), fetch(2)) runs both concurrently, and the result list matches the order of the arguments, not the order the calls finished in. It’s the closest thing to Promise.all .

2. Know what gather does with an error. By default, the first exception is raised straight to you, and the other calls are not cancelled: they keep running in the background.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.