Live data from Hacker News

Python has had async for 10 years – why isn't it more popular?

tonybaloney.github.io

111–120 of 305 posts

Re: Python has had async for 10 years – why isn't it more popular?

#111

Not popular? I use async all the time. The evidence this post provides is that flask and Django aren’t all in on async. That’s meaningless.

if you're going to lobby that criticism, you should atleast offer an alternative definition of popular...unless you're saying your usage of a tool defines its popularity

Re: Python has had async for 10 years – why isn't it more popular?

#113

Wow, didn't even see much about how miserable using the sync_to_async and async_to_sync transformers are. In general, the architectures developed because of the GIL, like Celery and gunicorn and stuff like that, handles most of the problems we run into that async/await solves with slightly better horizontal scaling IMO. The problem with a lot of async code is that it tends not to think beyond the single machine that'…

Not to mention sync_to_async and async_to_sync are also part of a library, asgiref that the Django developers made to wrap a thread pool runtime!

Re: Python has had async for 10 years – why isn't it more popular?

#114

The author gets close to what I think the root problem is, but doesn't call it out. The truth is that in python, async was too little, too late. By the time it was introduced, most people who actually needed to do lots of io concurrently had their own workarounds (forking, etc) and people who didn't actually need it had found out how to get by without it (multiprocessing etc). Meanwhile, go showed us what good green…

>most people who actually needed to do lots of io concurrently had their own workarounds (forking, etc) and people who didn't actually need it had found out how to get by without it (multiprocessing etc).

The problem is not python, it's a skill issue.

First of all forking is not a workaround, it's the way multiprocessing works at the low level in Unix systems.

Second of all, forking is multiprocessing, not multithreading.

Third of all, there's the standard threading library which just works well. There's no issue here, you don't need async.

Re: Python has had async for 10 years – why isn't it more popular?

#115
post #24

I think Python needs a good `fetch`-like async http client in the stdlib.

I personally recommend aiohttp. Setting up a ClientSession and letting it do its thing is quite nice.

httpx also supports sync and async, but I remember seeing an issue in their repo about worse performance than aiohttp.

Re: Python has had async for 10 years – why isn't it more popular?

#116

The author gets close to what I think the root problem is, but doesn't call it out. The truth is that in python, async was too little, too late. By the time it was introduced, most people who actually needed to do lots of io concurrently had their own workarounds (forking, etc) and people who didn't actually need it had found out how to get by without it (multiprocessing etc). Meanwhile, go showed us what good green…

green thread have pitfalls too, like this: https://news.ycombinator.com/item?id=39008026

FWIW this was largely fixed in 24 (I think there are still some edge cases relating to FFI functionality), and the 25 LTS should be coming this month.

Re: Python has had async for 10 years – why isn't it more popular?

#117

async python is awful. to me it is a by default avoid. and when you can't avoid, use only where it provides outsized benefit.

Sometimes less is more. When a program becomes so big, one of the hardest challenges is not to keep on adding stuff.

Re: Python has had async for 10 years – why isn't it more popular?

#118
post #78

It was supposed to bring massive concurrency to Python. But as with any async implantation in any language it is too easy to deadlock the entire system. Did you forgot to sprinkle enough `await`? Your code is blocked somewhere, good luck hunting for it. In contrast preemptive green threads are too easy. Be it IO or CPU load all threads will get their slice of CPU time. Nothing is blocked so you can debug your logic e…

It is even funnier because JS only got proper async after, what? 25 years or so of existence. The main reason JS went all in with async is because it only ever had a single event loop and that naturally fits with the async model.

I still remember the days when all the libs started adopting async and how so many of them (to this day) support both passing callbacks or returning promises. Async just so naturally fixed the callback hell of 2010s JS that it just became standard even though it is not even heavily used in the browser APIs.

Re: Python has had async for 10 years – why isn't it more popular?

#119

Earlier quoted context omitted.

> async, parallelism, concurrency, why not all three? async is a concurrency mechanism.

async enables a concurrency potential, nothing more That is, if you use external stuff and can delegate work to them, then async is concurrent (async io for instance) But if you do not, then async is regular code with extra steps

I do not understand what you mean, parallelism is running multiple concurrent execution blocks running in multiple physical CPUs at the same time.

My understanding is that JS can't do that (besides service workers which are non-shared memory), but it still has multiple concurrent code-blocks being executed at the same time, just in linear fashion. It will just never use multiple CPU cores at the same time (unless calling some non-JS non-shared-memory code)

Re: Python has had async for 10 years – why isn't it more popular?

#120
post #101

Earlier quoted context omitted.

It was memmove() on each task switch. So you could forget about d-cache. And that killed performance on anything but benchmarks.

Also caused subtle bugs. I once had to debug a crash in C++ code that turned out to be due to Stackless Python corrupting stack state on Windows. OutputDebugString() would intermittently crash because Stackless had temporarily copied out part of the stack and corrupted the thread's structured exception handling chain. This wasn't obvious because this occurred in a very deep call stack with Stackless much higher up, a…

We never ran stackless/greenlet under windows. And pycoev was setcontext(3)-based, so no windows either.

But I can imagine what that code did there...

Post reply on HN