Posted by willm 9/2/2025
One thing that I don't see being mentioned in any of the threads here talking about green threads is cancellation. A huge benefit, IMO, of anyio is that it makes cancellation really easy to handle. With asyncio, cancellation is pretty hard. And with green threads, cancellation is often impossible.
The traditional argument against the above assertion has been that asyncio is good for I/O work, not for CPU work, but this constraint is not realistic because CPU usage is guaranteed to creep in.
In summary, I can use threading/process/interpreter pools and concurrent futures, considering I need them anyway, without really needing to introduce yet another unnecessary concurrency paradigm (of asyncio).
The default linter in Vs Code keeps marking those functions with warnings though. Says I should mark them as async
With POSIX, you can only really do blocking filesystem I/O. There's an API for async I/O, where readiness of any read/write operation can either deliver a signal, or start a new thread. Neither of these scale at all. Things like select, poll, epoll all block, even with O_NONBLOCK.
So if your application needs to read files which may be large, or on a slow filesystem (or even networked filesystems!), you're now working with blocking I/O, at which point async can't help you.
---
Obviously this isn't the root cause of "why hasn't async taken over". It's just one of the many reasons which all pile up.
This is sort of like the article's Problem 3, but it's not just maintaining two APIs, it's even creating the second API in the first place.