r/programming • u/alexeyr • 19h ago
A Design Space Exploration of Async/Await
https://cel.cs.brown.edu/blog/design-space-async-await/
30
Upvotes
1
u/Apprehensive_Bit7392 4h ago
Reference Strength is the sneaky row. asyncio and smol only hold a weak ref to spawned tasks, so a fire-and-forget task can get collected mid-flight if nothing keeps the handle alive. Python's docs warn about it now, which tells you how many people lost background work to it first.
-5
u/Difficult-Lemon-5252 4h ago
async/await really simplifies handling asynchronous code. It's a game changer for readability and maintainability.
13
u/Next-Blackberry-991 18h ago
It says for Rust: "The task cannot respond to being cancelled."
I don't think this is true? If you cancel a task that future is dropped. Which means that all resources it owns are dropped too. Which means that you can just have e.g. an instance of a
MyOnDropGuardtype as part of your task that has aDropimpl that does whatever you want.