Modern APIs with FastAPI and Python Transcripts
Chapter: Course conclusion and review
Lecture: Review: async view methods

Login or purchase this course to watch this video and the rest of the course contents.
0:00 One of the most important things we can do for scalability and making our Web servers
0:05 handle more traffic with less hardware is to take the times where we're waiting on external services and allow other code to run.
0:12 Whether that's waiting on a deep database server to get back to us, calling an external API and waiting around for it to get back to us,
0:19 the ping time as stuff travels through the Internet and connecting all those different things. So we saw that FastAPI natively supports async methods.
0:29 It makes it super easy for us to work with them. So here to convert our weather API call to an async call,
0:36 we just put the word async def instead of def to define the function. And then when we call any async operations like get report
0:42 async, we just use the word await in front of it. That's it. Now we've gained tons of scalability by allowing the processing of other requests
0:50 while we're waiting on the report to come back to us.

Talk Python's Mastodon Michael Kennedy's Mastodon