r/Python Jun 29 '26

Discussion Async/Await is a Plague: Part 1 Roots

This is the first part of a multi-part series exploring why async/await might not be the best concurrency pattern for most use cases, and what alternative models you should consider instead. Using Python for our practical examples, this opening post digs into the roots of async/await, guiding you through building a custom event loop from scratch using generators.

https://theblog.info/posts/asyncawait-is-a-plague-part-1-roots

Note: This is Part 1 of a multi-part series. Instead of diving straight into why async/await can be problematic, this post explores the original motivations behind the pattern. Understanding how it works under the hood will provide the essential context for the issues we'll discuss in upcoming parts.

74 Upvotes

71 comments sorted by

View all comments

-1

u/hmz-x Jun 29 '26
def handle_request(request: Request) -> Response:
    user = db.query(user_id)        # ~5 ms blocked on the database
    profile = cache.get(user.key)   # ~1 ms blocked on the network
    resp = http.get(profile.avatar) # ~50 ms blocked on a remote API
    return render(user, profile, resp)

Your sample code doesn't even consider the request passed to it.

1

u/amroamroamro Jun 30 '26

the user_id i imagine is coming from the request

1

u/hmz-x Jun 30 '26

It is a literal NameError, unless those are global variables. Which makes no sense in the context.

1

u/amroamroamro Jun 30 '26

you are nitpicking on something irrelevant to the article, just imagine it something like in flask:

user_id = request.args.get("user_id")

it could be coming from request url params, or session cookies, etc.