How you explained asynchronous programming in Python is perfect. Not too advanced, and not too simple. Your examples with the times also was great and spot on!
I do have one question about your example when you ping /forgot-passwprd/user9/, though there is the underutilization of the thread workers in your example for Request 1 -- how can async help here?
Steps Endpoint resolution, Email exists in db?, and Generate token looks important and I don't think async would help here as these steps may be more synchronous!
Maybe for Send email async would work best!
Yes @Flex, for sending email async would definitely work the best. As SMTP network calls typically take seconds.
For checking if email exists in database, This is also a pretty complex IO bound task. CPU is literally waiting for the database drivers to get information. CPUs are super fast and databases are typically 1000s of times slower. So, async can help in database calls too.
My priority is to help build a production-ready application using FastAPI
I prioritize quality over simplicity. Our challenging approach ensures you're prepared for real-world development.
© Copyright 2022-2025 Team FastAPITutorial. All rights reserved.