• atomicnumber3 7 hours ago

    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 threads can look like. Then java did it too. Meanwhile, js had better async support the whole time. But all it did was show us that async code just plain sucks compared to green thread code that can just block, instead of having to do the async dances.

    So, why engage with it when you already had good solutions?

    • jacquesm 16 minutes ago

      There are much better solutions for the same problems, but not in Python. If you really need such high throughput you'd move to Go, the JVM or Erlang/Elixer depending on the kind of workload you have rather than to much around with Python on something that it clearly was never intended to do in the first place. It is amazing they got it to work as well as it does but the impedance mismatch is pretty clear and it will never feel natural.

      • throw-qqqqq 7 hours ago

        > But all it did was show us that async code just plain sucks compared to green thread code that can just block, instead of having to do the async dances.

        I take so much flak for this opinion at work, but I agree with you 100%.

        Code that looks synchronous, but is really async, has funny failure modes and idiosyncracies, and I generally see more bugs in the async parts of our code at work.

        Maybe I’m just old, but I don’t think it’s worth it. Syntactic sugar over continuations/closures basically..

        • lacker 6 hours ago

          I'm confused, I feel like the two of you are expressing opposite opinions.

          The comment you are responding to prefers green threads to be managed like goroutines, where the code looks synchronous, but really it's cooperative multitasking managed by the runtime, to explicit async/await.

          But then you criticize "code that looks synchronous but is really async". So you prefer the explicit "async" keywords? What exactly is your preferred model here?

          • throw-qqqqq 6 hours ago

            First, I don’t mean to criticize anything or anyone. People value such things subjectively, but for me the async/sync split does no good.

            Goroutines feel like old-school, threaded code to me. I spawn a goroutine and interact with other “threads” through well defined IPC. I can’t tell if I’m spawning a green thread or a “real” system thread.

            C#’s async/await is different IMO and I prefer the other model. I think the async-concept gets overused (at my workplace at least).

            If you know Haskell, I would compare it to overuse of laziness, when strictness would likely use fewer resources and be much easier to reason about. I see many of the same problems/bugs with async/await..

            • thomasahle an hour ago

              Comparing to Haskell, I think of "async" as the IO monad. It's nice to have all code that does IO flagged explicitly as such.

              • eddd-ddde 2 hours ago

                Wouldn't the old school style be more like rust async? Simple structs that you poll whenever you need to explicitly. No magic code that looks synchronous but isn't.

              • throwaway81523 3 hours ago

                No, goroutines are preemptive. They avoid async hazards though of course introduce some different ones.

                • Yoric 3 hours ago

                  To be fair, it depends on the version of Go.

                  Used to be well-hidden cooperative, these days it's preemptive.

                  • throwaway81523 2 hours ago

                    It changed for a reason.

              • kibwen 6 hours ago

                > Code that looks synchronous, but is really async, has funny failure modes and idiosyncracies

                But this appears to be describing languages with green threads, rather than languages that make async explicit.

                • pclmulqdq 6 hours ago

                  Without the "async" keyword, you can still write async code. It looks totally different because you have to control the state machine of task scheduling. Green threads are a step further than the async keyword because they have none of the function coloring stuff.

                  You may think of use of an async keyword as explicit async code but that is very much not the case.

                  If you want to see async code without the keyword, most of the code of Linux is asynchronous.

                  • Dylan16807 6 hours ago

                    Having to put "await" everywhere is very explicit. I'd even say it's equally explicit to a bunch of awkward closures. Why do you say it's less?

                    • throwawayffffas 3 hours ago

                      Because it hides away the underlying machinery.

                      Everything is in a run loop that does not exist in my codebase.

                      The context switching points are obvious but the execution environment is opaque.

                      At least that's how it looks to me.

                      • toast0 2 hours ago

                        The problem isn't that it hides away the machinery. The problem is that it hides some things, but not everything. Certainly a lot of stuff hides behind await/async. But as a naive developer who is used to real threads and green threads, I expected there would be some wait to await on a real thread and all the async stuff would just happen... but instead, if you await, actually you've got to be async too. If you had to write your async code where you gave an eventloop a FD and a callback to run when it was ready, that would be more explicit, IMHO... but it would be so wordy that it would only get used under extreme duress... I've worked on those code bases and they can do amazing things, but if there's any complexity it quickly becomes not worth it.

                        Green threads are better (IMHO), because they actually do hide all the machinery. As a developer in a language with mature green threads (Erlang), I don't have to know about the machinery[1], I just write code that blocks from my perspective and BEAM makes magic happen. As I understand it, that's the model for Java's Project Loom aka Java Green Threads 2: 2 Green 2 Threads. The first release had some issues with the machinery, but I think I read the second release was much better, and I haven't seen much since... I'm not a Cafe Babe, so I don't follow Java that closely.

                        [1] It's always nice to know about the machinery, but I don't have to know about it, and I was able to get started pretty quick and figure out the machinery later.

                        • ForHackernews 2 hours ago

                          I don't understand this criticism. The JVM is opaque, App Engine is opaque, Docker is opaque. All execution environments are opaque unless you've attached a debugger and are manually poking at the thing while it runs.

                        • throw-qqqqq 5 hours ago

                          > Why do you say it's less

                          Let me try to clarify my point of view:

                          I don’t mean that async/await is more or less explicit than goroutines. I mean regular threaded code is more explicit than async/await code, and I prefer that.

                          I see colleagues struggle to correctly analyze resource usage for instance. Someone tries to parallelize some code (perhaps naiively) by converting it to async/await and then run out of memory.

                          Again, I don’t mean to judge anyone. I just observe that the async/await-flavor has more bugs in the code bases I work on.

                          • curt15 4 hours ago

                            >I don’t mean that async/await is more or less explicit than goroutines. I mean regular threaded code is more explicit than async/await code, and I prefer that.

                            More explicit in what sense? I've written both regular threaded Python and async/await Python. Only the latter shows me precisely where the context switches occur.

                          • pclmulqdq 5 hours ago

                            It's explicit that the code is async, but how the asynchrony happens is completely implicit with async/await, and is managed by a runtime of some kind.

                            Kernel-style async code, where everything is explicit:

                            * You write a poller that opens up queues and reads structs representing work

                            * Your functions are not tagged as "async" but they do not block

                            * When those functions finish, you explicitly put that struct in another queue based on the result

                            Async-await code, where the runtime is implicit:

                            * All async functions are marked and you await them if they might block

                            * A runtime of some sort handles queueing and runnability

                            Green threads, where all asynchrony is implicit:

                            * Functions are functions and can block

                            * A runtime wraps everything that can block to switch to other local work before yielding back to the kernel

                            • lstodd 3 hours ago

                              > Green threads, where all asynchrony is implicit:

                              which are no different from app POV from kernel threads, or any threads for that matter.

                              the whole async stuff came up because context switch per event is way more expensive than just shoveling down a page of file descriptor state.

                              thus poll, kqueue, epoll, io_uring, whatever.

                              think of it as batch processing

                          • throw-qqqqq 6 hours ago

                            This is exactly what I mean.

                            Thank you for explaining much more clearly than I could.

                            > none of the function coloring stuff

                            And it’s this part that I don’t like (and see colleagues struggling to implement correctly at work).

                        • markandrewj 3 hours ago

                          I can tell you guys work with languages like Go, so this isn't true for yourselves, but I usually find it is developers that only ever work with synchronous code who find async complicated. Which isn't surprising, if you don't understand something it can seem complicated. My views is almost that people should learn how to write async code by default now. Regardless of the language. Writing modern applications basically requires it, although not all the time obviously.

                          • Yoric 3 hours ago

                            Hey, I'm one of the (many, many) people who made async in JavaScript happen and I find async complicated.

                          • larusso 6 hours ago

                            async is like a virus. I think the implementation in js and .NET is somewhat ok’ish because your code is inside an async context most of the time. I really hate the red / blue method issues where library functions get harder to compose. Oh I have a normal method because there was no need for async. Now I change the implementation and need to call an async method. There are ways around this but more often than not will you change most methods to be async.

                            To be fair that also happens with other solutions.

                            • DanielHB 4 hours ago

                              It is not nearly as much of a problem in JS because JS only has an event loop, there is no way to mix in threads with async code because there are no threads. Makes everything a lot simpler and a lot of the data structures a lot faster (because no locks required). But actual parallelization (instead of just concurrency) is impossible[1].

                              A lot of the async problems in other languages is because they haven't bought up into the concept fully with some 3rd party code using it and some don't. JS went all-in with async.

                              [1]: Yes I know about service workers, but they are not threads in the sense that there is no shared memory*. It is good for some types of parallelization problems, but not others because of all the memory copying required.

                              [2]: Yes I know about SharedArrayBuffer and there is a bunch of proposals to add support for locks and all that fun stuff to them, which also brings all the complexity back.

                            • Uptrenda 3 hours ago

                              I'm a person who wrote an entire networking library in Python and I agree with you. The most obvious issue with Python's single-threaded async code is any slow part of the program delays the entire thing. And yeah -- that's actually insanely frigging difficult to avoid. You write standard networking code and then find out that parts you expected to be async in Python actually ended up being sync / blocking.

                              DESPITE THAT: even if you're doing everything "right" (TM) -- using a single thread and doing all your networking I/O sequentially is simply slow as hell. A very very good example of this is bottle.py. Lets say you host a static web server with bottle.py. Every single web request for files leads to sequential loading, which makes page load times absolutely laughable. This isn't the case for every python web frame work, but it seems to be a common theme to me. (Cause: single thread, event loop.)

                              With asyncio, the most consistent behavior I've had with it seems to be to avoid having multiple processes and then running event loops inside them. Even though this approach seems like its necessary (or at least threading) to avoid the massive down sides of the event loop. But yeah, you have to keep everything simple. In my own library I use a single event loop and don't do anything fancy. I've learned the hard way how asyncio punishes trying to improve it. It's a damn cool piece of software, just has some huge limitations for performance.

                            • pnathan 6 hours ago

                              Async taints code, and async/await fall prey to classic cooperative multitasking issues. "What do you mean that this blocked that?"

                              The memory and execution model for higher level work needs to not have async. Go is the canonical example of it done well from the user standpoint IMO.

                              • hinkley 4 hours ago

                                The function color thing is a real concern. Am I wrong or did a python user originally coin that idea?

                                • throwawayffffas 2 hours ago

                                  No it was a js dev complaining about callbacks in node. Mainly because a lot of standard library code back then only came in callback flavour. i.e. no sync file writes, etc.

                                  • munificent an hour ago

                                    I wrote it. :)

                                    Actually, I was and am primarily a Dart developer, not a JS developer. But function color is a problem in any language that uses that style of asynchrony: JS, Dart, etc.

                                    • LtWorf 2 hours ago

                                      Which is really funny because the linux kernel doesn't do async for file writes :D

                                  • meowface an hour ago

                                    gevent has been in Python for ages and still works great. It basically adds goroutine-like green thread support to the language. I still generally start new projects with gevent instead of asyncio, and I think I always will.

                                    • pdonis 32 minutes ago

                                      I've used gevent and I agree it works well. It has prevented me from even trying to experiment with the async/await syntax in Python for anything significant.

                                      However, gevent has to do its magic by monkeypatching. Wanting to avoid that, IIRC, was a significant reason why the async/await syntax and the underlying runtime implementation was developed for Python.

                                      Another significant reason, of course, was wanting to make async functions look more like sync functions, instead of having to be written very differently from the ground up. Unfortunately, requiring the "async" keyword for any async function seriously detracted from that goal.

                                      To me, async functions should have worked like generator functions: when generators were introduced into Python, you didn't have to write "gen def" or something like it instead of just "def" to declare one. If the function had the "yield" keyword in it, it was a generator. Similarly, if a function has the "await" keyword in it, it should just automatically be an async function, without having to use "async def" to declare it.

                                  • gen220 7 hours ago

                                    As somebody who's written and maintained a good bit of Python in prod and recently a good amount of server-side typescript... this would be my answer.

                                    I'd add one other aspect that we sort of take for granted these days, but affordable multi-threaded CPUs have really taken off in the last 10 years.

                                    Not only does the stack based on green-threads "just work" without coloring your codebase with async/no-async, it allows you to scale a single compute instance gracefully to 1 instance with N vCPUs vs N pods of 2-vCPU instances.

                                    • hinkley 4 hours ago

                                      Async is pretty good “green threads” on its own. Coroutines can be better, but they’re really solving an overlapping set of problems. Some the same, some different.

                                      In JavaScript async doesn’t have a good way to nice your tasks, which is an important feature of green threads. Sindre Sorhus has a bunch of libraries that get close, but there’s still a hole.

                                      What coroutines can do is optimize the instruction cache. But I’m not sure goroutines entirely accomplish that. There’s nothing preventing them from doing so but implementation details.

                                      • 6r17 2 hours ago

                                        I feel like async is just an easier way to reason about something but it leaves out a lot of cheating open ; tough sometimes it's just more comfortable to write - but that cheating comes with a lot of hidden responsibilities that are just not presented in python (things like ownership) - even tough it present tools to properly solve these issues - anyone who would really want to dive into technical wouldn't choose python anyway

                                        • b33j0r 6 hours ago

                                          For me, once I wanted to scale asyncio within one process (scaling horizontally on top of that), only two things made sense: rust with tokio or node.js.

                                          Doing async in python has the same fundamental design. You have an executer, a scheduler, and event-driven wakers on futures or promises. But you’re doing it in a fundamentally hand-cuffed environment.

                                          You don’t get benefits like static compilation, real work-stealing, a large library ecosystem, or crazy performance boosts. Except in certain places in the stack.

                                          Using fastapi with async is a game-changer. Writing a cli to download a bunch of stuff in parallel is great.

                                          But if you want to use async to parse faster or make a parallel-friendly GUI, you are more than likely wasting your time using python. The benefits will be bottlenecked by other language design features. Still the GIL mostly.

                                          I guess there is no reason you can’t make tokio in python with multiprocessing or subinterpreters, but to my knowledge that hasn’t been done.

                                          Learning tokio was way more fun, too.

                                          • hinkley 3 hours ago

                                            I don’t know where Java is now but their early promise and task queue implementations left me feeling flat. And people who should know better made some dumb mistakes around thread to CPU decisions that just screamed “toy solution”. They didn’t compose.

                                            • ciupicri 6 hours ago

                                              GIL is not part of the language design, it's just a detail of the most common implementation - CPython.

                                              • b33j0r 6 hours ago

                                                Fair and accurate. But that’s pretty much what people use, right?

                                                I am happy to hear stories of using pypy or something to radically improve an architecture. I don’t have any from personal experience.

                                                I guess twisted and stackless, a long time ago.

                                              • smw 6 hours ago

                                                Or just golang?

                                                • iknowstuff 6 hours ago

                                                  Segfaults

                                              • pkulak 2 hours ago

                                                Green threads can be nicer to program in, but it’s not like there’s no cost. You still need a stack for every green thread, just like you need one for every normal thread. I think it’s worth it to figure out a good system for stackless async. Something like Kotlin is about as good as it gets. Rust is getting there, despite all the ownership issues, which would exist in green threads too.

                                                • gshulegaard 5 hours ago

                                                  I also think asyncio missed the mark when it comes to it's API design. There are a lot of quirks and rough edges to it that, as someone who was using `gevent` heavily before, strike me as curious and even anti-productive.

                                                  • neuroelectron 7 hours ago

                                                    Even in Java, async is rarely the right solution. I'm sure in situations where it's needed, Python's async would be used. For instance, it would be good for reducing resource usage in any kind of small service that dynamically scales. The workarounds are much more expensive but that doesn't matter unless you're already resource constrained.

                                                    Even then, nginx might be a netter solution.

                                                    • jayd16 6 hours ago

                                                      > But all it did was show us that async code just plain sucks compared to green thread code that can just block, instead of having to do the async dances.

                                                      I'll be sold on this when a green thread native UI paradigm becomes popular but it seems like all the languages with good native UI stories have async support.

                                                      • parhamn 7 hours ago

                                                        pair this with needing async in depth and that's exactly it. The whole network stack needs to be async-first and all the popular networking libraries need to have been built on that. Many of those libraries are already C-extension based and don't jibe well with the newer python parts in any way.

                                                        • hinkley 3 hours ago

                                                          Java is trying to do this but I haven’t read how that’s going.

                                                        • leecarraher 3 hours ago

                                                          i agree, also add to that, that many python modules are foss projects that are maintained on a limited basis or budget. Refactoring code that may have some unsafe async routines would be costly for an org, and dreadful for recreation. So you can either have a rich library of modules, or go async and risk something you need not working then having to find a workaround. Personally, if parallelism is important enough, i use ctypes and openmp. If i need something more portable, i have a few multiprocessing wrappers that implement prange and a few other widgets for shared memory.

                                                          • ddorian43 7 hours ago

                                                            Because it sucks compared to gevent (green threads). But for some reason, people always disregard this option. They don't even read it. Like any comment with gevent is shadowbanned and it doesn't register in their mind.

                                                            • int_19h 3 hours ago

                                                              The fundamental problem with any kind of green threads is that they require runtime support which doesn't play well with any active stack frames that aren't aware that they are on a green thread (which can be switched).

                                                              • nromiun 6 hours ago

                                                                Gevent is too underrated. Even if people don't like the monkey patching you can simply use the gevent namespace API as well. No idea why people prefer the absolute mess that is Python async ecosystem.

                                                                • meowface an hour ago

                                                                  I've used gevent for years and will probably never stop. I greatly prefer it (or Go) over asyncio.

                                                                  People act like it's dead but it still works perfectly well and, at least for me, makes async networking so much simpler.

                                                                  • jononor 6 hours ago

                                                                    Happily using gevent for our backend (IoT+ML) since 2019. Was very glad when I saw it is still being well supported by recent SQLAlchemy and pscycopg releases.

                                                                  • JackSlateur 7 hours ago

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

                                                                    • kasperni 6 hours ago

                                                                      This was a known issue and was fixed in Java 24 [1].

                                                                      [1] https://openjdk.org/jeps/491

                                                                      • hueho 4 hours ago

                                                                        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.

                                                                        • ronsor 6 hours ago

                                                                          This doesn't look like a problem with green threads so much as it is a problem with Java's implementation of them. Of course, Java is known for having problems with its implementations of many different things, such as sandboxing; this isn't special.

                                                                        • TZubiri 4 hours ago

                                                                          >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.

                                                                          • jongjong 3 hours ago

                                                                            Yes and JS had a smooth on-ramp to async/await thanks to Promises.

                                                                            Promises/thenables gave people the time to get used to the idea of deferred evaluation via a familiar callback approach... Then when async/await came along, people didn't see it as a radically new feature but more as syntactic sugar to do what they were already doing in a more succinct way without callbacks.

                                                                            People in the Node.js community were very aware of async concepts since the beginning and put a lot of effort in not blocking the event loop. So Promises and then async/await were seen as solutions to existing pain points which everyone was already familiar with. A lot of people refactored their existing code to async/await.

                                                                            • laurencerowe 2 hours ago

                                                                              JavaScript’s Promises were of course heavily influenced by Twisted’s Deferreds in Python, from the days before async/await.

                                                                            • LtWorf 2 hours ago

                                                                              forking and async are totally different things.

                                                                              • pulse7 5 hours ago

                                                                                "Then java did it too." Java had green threads in 1.0. They were removed. Then Java added virtual threads.

                                                                                • pbalau 6 hours ago

                                                                                  You make a very good case for why python's async isn't more prevalent, but I think this is not painting the full image.

                                                                                  Taking a general case, let's say a forum, in order to render a thread one needs to search for all posts from that thread, then get all the extra data needed for rendering and finally send the rendered output to the client.

                                                                                  In the "regular" way of doing this, one will compose a query, that will filter things out, join all the required data bla bla, send it to the database, wait for the answer from the database and all the data to be transferred over, loop over the results and do some rendering and send the thing over to the client.

                                                                                  It doesn't matter how async your app code is, in this way of doing things, the bottle neck is the database, as there is a fixed limit on how many things a db server can do at once and if doing one of these things takes a long time, you still end up waiting too much.

                                                                                  In order for async to work, one needs to split the work load into very small chunks that can be done in parallel and very fast, therefore, sending a big query and waiting for all the result data is out of the window.

                                                                                  An async approach would split the db query into a search query, that returns a list of object ids, say posts, then create N number of async tasks that given a post id will return a rendered result. These tasks will do their own query to retrieve the post data, then assemble another list of async tasks to get all the other data required and render each chunk and so on. Throw in a bunch of db replicas and you get the benefits of async.

                                                                                  This approach is not generally used, because, let's face it, we like making the systems we use do complicated things, eg complicated sql requests.

                                                                                • xg15 6 hours ago

                                                                                  I learned about the concept of async/await from JS and back then was really amazed by the elegance of it.

                                                                                  By now, the downsides are well-known, but I think Python's implementation did a few things that made it particularly unpleasant to use.

                                                                                  There is the usual "colored functions" problem. Python has that too, but on steroids: There are sync and async functions, but then some of the sync functions can only be called from an async function, because they expect an event loop to be present, while others must not be called from an async function because they block the thread or take a lot of CPU to run or just refuse to run if an event loop is detected. That makes at least four colors.

                                                                                  The API has the same complexity: In JS, there are 3 primitives that you interact with in code: Sync functions, async functions and promises. (Understanding the event loop is needed to reason about the program, but it's never visible in the code).

                                                                                  Whereas Python has: Generators, Coroutines, Awaitables, Futures, Tasks, Event Loops, AsyncIterators and probably a few more.

                                                                                  All that for not much benefit in everyday situations. One of the biggest advantages of async/await was "fearless concurrency": The guarantee that your variables can only change at well-defined await points, and can only change "atomically". However, python can't actually give the first guarantee, because threaded code may run in parallel to your async code. The second guarantee already comes for free in all Python code, thanks to the GIL - you don't need async for that.

                                                                                  • mcdeltat 4 hours ago

                                                                                    I think Python async is pretty cool - much nicer than threading or multiprocessing - yet has a few annoying rough edges like you say. Some specific issues I run into every time:

                                                                                    Function colours can get pretty verbose when you want to write functional wrappers. You can end up writing nearly the exact same code twice because one needs to be async to handle an async function argument, even if the real functionality of the wrapper isn't async.

                                                                                    Coroutines vs futures vs tasks are odd. More than is pleasant, you have one but need the other for an API for no intuitive reason. Some waiting functions work on some types and not on others. But you can usually easily convert between them - so why make a distinction in the first place?

                                                                                    I think if you create a task but don't await it (which is plausible in a server type scenario), it's not guaranteed to run because of garbage collection or something. That's weird. Such behaviour should be obviously defined in the API.

                                                                                    • tylerhou 2 hours ago

                                                                                      > You can end up writing nearly the exact same code twice because one needs to be async to handle an async function argument, even if the real functionality of the wrapper isn't async.

                                                                                      Sorry for the possibly naive question. If I need to call a synchronous function from an async function, why can't I just call await on the async argument?

                                                                                          def foo(bar: str, baz: int):
                                                                                            # some synchronous work
                                                                                            pass
                                                                                          
                                                                                          async def other(bar: Awaitable[str]):
                                                                                            foo(await bar, 0)
                                                                                      • xg15 3 hours ago

                                                                                        I think the general idea of function colors has some merit - when done right, it's a crude way to communicate information about a function's expected runtime in a way that can be enforced by the environment: A sync function is expected to run short enough that it's not user-perceptible, whereas an async function can run for an arbitrary amount of time. In "exchange", you get tools to manage the async function while it runs. If a sync function runs too long (on the event loop) this can be detected and flagged as an error.

                                                                                        Maybe a useful approach for a language would be to make "colors" a first-class part of the type system and support them in generics, etc.

                                                                                        Or go a step further and add full-fledged time complexity tracking to the type system.

                                                                                    • nateglims 2 hours ago

                                                                                      The API complexity really threw me when I last tried async python. It's very different from other async systems and is incredibly different from gevent or twisted which were popular when I was last writing server python.

                                                                                      • gloomyday 6 hours ago

                                                                                        I remember trying to use async in Python for the first time in 2017, and I actually found it easier to learn the basics of Go to create a coroutine, export it as a shared library, and create the bindings. I'm not exaggerating.

                                                                                        If I remember correctly, the Python async API was still in experimental phase at that time.

                                                                                        • int_19h 3 hours ago

                                                                                          Generators are orthogonal to all this. They are the equivalent of `function*` in JS. And yes, they are also coroutines, but experience has shown that keeping generators separate from generic async functions is more ergonomic (hence why C# and JS both do the same thing).

                                                                                          • xg15 3 hours ago

                                                                                            True. I think the connection is more a historical one became the first async implementation was done using generators and lots of "yield from" statements AFAIK.

                                                                                            But I think generators are still sometimes mentioned in tutorials for this reason.

                                                                                            • int_19h 3 hours ago

                                                                                              Implementing what was essentially an equivalent of `await` on top of `yield` (before we got `yield from` even) was a favorite pastime at some point. I worked on a project that did exactly that for WinRT projection to Python. And before that there was Twisted. It's very tempting because it gets you like 90% there. But then eventually you want something like `async for` etc...

                                                                                          • Retr0id 6 hours ago

                                                                                            > some of the sync functions can only be called from an async function, because they expect an event loop to be present

                                                                                            I recognise that this situation is possible, but I don't think I've ever seen it happen. Can you give an example?

                                                                                            • xg15 5 hours ago

                                                                                              Everything that directly interacts with an event loop object and calls methods such as loop.call_soon() [1].

                                                                                              This is used by most of asyncio's synchronization primitives, e.g. async.Queue.

                                                                                              A consequence is that you cannot use asyncio Queues to pass messages or work items between async functions and worker threads. (And of course you can't use regular blocking queues either, because they would block).

                                                                                              The only solution is to build your own ad-hoc system using loop.call_soon_threadsafe() or use third-party libs like Janus[2].

                                                                                              [1] https://github.com/python/cpython/blob/e4e2390a64593b33d6556...

                                                                                              [2] https://github.com/aio-libs/janus

                                                                                          • matthew16550 3 minutes ago

                                                                                            Pythons builtin async always confuses me.

                                                                                            The Trio library felt easy to learn and just worked without much fuss.

                                                                                            https://trio.readthedocs.io/

                                                                                            • svieira 7 hours ago

                                                                                              I used to keep plugging Unyielding [1] vs. What Color Is Your Function [2] as the right matrix to view these issues within. But then Notes on structured concurrency [3] was written and I just point to that these days.

                                                                                              But, to sum it all up for those who want to talk here, there are several ways to look at concurrency but only one that matters. Is my program correct? How long will it take to make my program correct? Structured concurrency makes that clear(er) in the syntax of the language. Unstructured concurrency requires that you hold all the code in your head.

                                                                                              [1]: https://glyph.twistedmatrix.com/2014/02/unyielding.html

                                                                                              [2]: https://journal.stuffwithstuff.com/2015/02/01/what-color-is-...

                                                                                              [3]: https://vorpus.org/blog/notes-on-structured-concurrency-or-g...

                                                                                            • rybosome 7 hours ago

                                                                                              I suppose my negative experiences with async fall under #3, that it is hard to maintain two APIs.

                                                                                              One of the most memorable "real software engineering" bugs of my career involved async Python. I was maintaining a FastAPI server which was consistently leaking file descriptors when making any outgoing HTTP requests due to failing to close the socket. This manifested in a few ways: once the server ran out of available file descriptors, it degraded to a bizarre world where it would accept new HTTP requests but then refuse to transmit any information, which was also exciting due to increasing the difficulty of remotely debugging this. Occasionally the server would run out of memory before running out of file descriptors on the OS, which was a fun red herring that resulted in at least one premature "I fixed the problem!" RAM bump.

                                                                                              The exact culprit was never found - I spent a full week debugging it, and concluded that the problem had to do with someone on the library/framework/system stack of FastAPI/aiohttp/asyncio having expectations about someone else in the stack closing the socket after picking up the async context, but that never actually occurring. It was impenetrable to me due to the constant context switching between the libraries and frameworks, such that I could not keep the thread of who (above my application layer) should have been closing it.

                                                                                              My solution was to monkey patch the native python socket class and add a FastAPI middleware layer so that anytime an outgoing socket opened, I'd add it to a map of sockets by incoming request ID. Then when the incoming request concluded I'd lookup sockets in the map and close them manually.

                                                                                              It worked, the servers were stable, and the only follow-up request was to please delete the annoying "Socket with file descriptor <x> manually closed" message from the logs, because they were cluttering things up. And thus, another brick in the wall of my opinion that I do not prefer Python for reliable, high-performance HTTP servers.

                                                                                              • Scramblejams 5 hours ago

                                                                                                > it is hard to maintain two APIs.

                                                                                                This point doesn't get enough coverage. When I saw async coming into Python and C# (the two ecosystems I was watching most closely at the time) I found it depressing just how much work was going into it that could have been productively expended elsewhere if they'd have gone with blocking calls to green threads instead.

                                                                                                To add insult to injury, when implementing async it seems inevitable that what's created is a bizarro-world API that mostly-mirrors-but-often-not-quite the synchronous API. The differences usually don't matter, until they do.

                                                                                                So not only does the project pay the cost of maintaining two APIs, the users keep paying the cost of dealing with subtle differences between them that'll probably never go away.

                                                                                                > I do not prefer Python for reliable, high-performance HTTP servers

                                                                                                I don't use it much anymore, but Twisted Matrix was (is?) great at this. Felt like a superpower to, in the oughties, easily saturate a network interface with useful work in Python.

                                                                                                • lormayna 5 hours ago

                                                                                                  > I don't use it much anymore, but Twisted Matrix was (is?) great at this.

                                                                                                  You must be an experienced developer to write maintenable code with Twisted, otherwise, when the codebase increase a little, it will quickly become a bunch of spaghetti code.

                                                                                                • stackskipton 3 hours ago

                                                                                                  Glad I'm not only one in the boat. We have Python HTTP Server doing similar. No one can figure it out, Containerd occasionally OOM kills it, everyone just shrugs and move on.

                                                                                                • PaulHoule 7 hours ago

                                                                                                  I went through a phase of writing asyncio servers for my side projects. Probably the most fun I had was writing things that were responsive in complex ways, such as a websockets server that was also listening on message queues or on a TCP connection to a Denon HEOS music player.

                                                                                                  Eventually I wrote an "image sorter" that I found was hanging up when the browser was trying to download images in parallel, the image serving should not have been CPU bound, I was even using sendfile(), but I think other requests would hold up the CPU and would be block the tiny amount of CPU needed to set up that sendfile.

                                                                                                  So I switched from aiohttp to the flask API and serve with either Flask or Gunicorn, I even front it with Microsoft IIS or nginx to handle the images so Python doesn't have to. It is a minor hassle because I develop on Windows so I have to run Gunicorn inside WSL2 but it works great and I don't have to think about server performance anymore.

                                                                                                  • Townley 3 hours ago

                                                                                                    It’s heartening that there are people who find the problem you described “fun”

                                                                                                    Writing a FastAPI websocket that reads from a redis pubsub is a documentation-less flailfest

                                                                                                    • tdumitrescu 7 hours ago

                                                                                                      That's the main problem with evented servers in general isn't it? If any one of your workloads is cpu-intensive, it has the potential to block the serving of everything else on the same thread, so requests that should always be snappy can end up taking randomly long times in practice. Basically if you have any cpu-heavy work, it shouldn't go in that same server.

                                                                                                      • acdha 7 hours ago

                                                                                                        Indeed. async is one of those things which makes a big difference in a handful of scenarios but which got promoted as a best-practice for everything. Python developers have simply joined Node and Go developers in learning that it’s not magic “go faster” spray and reasoning about things like peak memory load or shared resource management can be harder.

                                                                                                        • materielle 3 hours ago

                                                                                                          Traditionally, there are two strategies:

                                                                                                          1) Use the network thread pool to also run application code. Then your entire program has to be super careful to not block or do CPU intensive work. This is efficient but leads to difficult to maintain programs.

                                                                                                          2) The network thread pool passes work back and forth between an application executor. That way, the network thread pool is never starved by the application, since it is essentially two different work queues. This works great, but now every request performs multiple thread hops, which increases latency.

                                                                                                          There has been a lot of interest lately to combine scheduling and work stealing algorithms to create a best of both worlds executor.

                                                                                                          You could imagine, theoretically, an executor that auto-scales, and maintains different work queues and tries to avoid thread hops when possible. But ensures there are always threads available for the network.

                                                                                                          • PaulHoule 5 hours ago

                                                                                                            My system is written in Python because it is supported by a number of batch jobs that use code from SBERT, scikit-learn, numpy and such. Currently the server doesn't do any complex calculations but under asyncio it was a strict no-no. Mostly it does database queries and formats HTML responses but it seems like that is still too much CPU.

                                                                                                            My take on gunicorn is that it doesn't need any tuning or care to handle anything up to the large workgroup size other than maybe "buy some more RAM" -- and now if I want to do some inference in the server or use pandas to generate a report I can do it.

                                                                                                            If I had to go bigger I probably wouldn't be using Python in the server and would have to face up to either dual language or doing the ML work in a different way. I'm a little intimidated about being on the public web in 2025 though with all the bad webcrawlers. Young 'uns just never learned everything that webcrawler authors knew in 1999. In 2010 there were just two bad Chinese webcrawlers that never sent a lick of traffic to anglophone sites, but now there are new bad webcrawlers every day it seems.

                                                                                                            • nly 6 hours ago

                                                                                                              OS threads are for CPU bound work.

                                                                                                              Async is for juggling lots of little initialisations, completions, and coordinating work.

                                                                                                              Many apps are best single threaded with a thread pool to run (single threaded) long running tasks.

                                                                                                          • mjd 7 hours ago

                                                                                                            I haven't read the article yet, but I do have something to contribute: several years ago I was ay PyCon and saw a talk in which someone mentioned async. I was interested and wanted to learn to use it. But I found there was no documentation at all! The syntax was briefly described, but not the semantics.

                                                                                                            I realized, years later, that the (non-)documentation was directed at people who were already familiar with the feature from Javascript. But I hadn't been familiar with it from Javascript and I didn't even know that Javascript had had such a feature.

                                                                                                            So that's my tiny contribution to this discussion, one data point: Python's async might have been one unit more popular if it had had any documentation, or even a crossreference to the Javascript documentation.

                                                                                                            • notatoad 7 hours ago

                                                                                                              this was my initial experience with python async as well (which i now use heavily)

                                                                                                              the documentation is directed at people who want coroutines and futures, and know what that means. if you don't know what coroutines and futures are, the python docs aren't going to help you. the documentation isn't going to guide anybody into using the async features who aren't already seeking them out. and maybe that's intentional, but it's not going to grow adoption of the async features.

                                                                                                              • int_19h 3 hours ago

                                                                                                                FWIW Python got async/await before JavaScript did. I believe at the time the main inspiration was C#.

                                                                                                                • lyu07282 2 hours ago

                                                                                                                  JavaScript was always single-threaded asynchronous, the added async/await keywords were just syntactic sugar. Node.js became popular before it as well, though I found at the time it was difficult to avoid callback hell similar to using libuv directly in C.

                                                                                                                  • int_19h an hour ago

                                                                                                                    async/await was syntactic sugar in C# as well. Callbacks are a natural way to do async so it's no surprise.

                                                                                                                    And while Python implements async directly in the VM, its semantics is such that it can be treated as syntactic sugar for callbacks there also.

                                                                                                              • languagehacker 6 hours ago

                                                                                                                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's running it, and by the time you do, you need to rearchitect things to scale better horizontally anyway.

                                                                                                                For most Python applications, especially with web development, just start with something like Celery and you're probably fine.

                                                                                                                • operator-name 4 hours ago

                                                                                                                  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!

                                                                                                                • TheCondor 2 hours ago

                                                                                                                  I generally like Python. I'm not a hater but I don't treat it like a religion either.

                                                                                                                  Async Python is practically a new language. I think for most devs, it's a larger than than 2 to 3 was. One of the things that made python uptake easy was the vast number of libraries and bindings to C libraries. With async you need new versions of that stuff, you can definitely use synchronous libraries but then you get to debug why your stuff blocks.

                                                                                                                  Async Python is a different debugging experience for most python engineers. I support a small handful of async python services and think it would be an accellerator for our team to rewrite them on Go.

                                                                                                                  When you hire python engineers, most don't know async that well, if at all.

                                                                                                                  If you have a mix of synchronous and asynchronous code in your org, you can't easily intermix it. Well you can, but it won't behave as you usually desire it to, it's probably more desirable to treat them as different code bases.

                                                                                                                  Not to be too controversial, but depending upon your vintage and they was you've learned to write software I think you can come to python and think async is divine manna. I think there are many more devs that come to python from datascience or scripting or maybe as a first language and I think they have a harder time accepting the value and need of async. Like I said above, it's almost an entirely different language.

                                                                                                                  • KaiserPro 7 hours ago

                                                                                                                    the two issues I have with async is are:

                                                                                                                    1) its infectious. You need to wrap everything in async or nothing.

                                                                                                                    2) it has non-obvious program flow.

                                                                                                                    Even though it is faster in a lot of cases (I had a benchmark off for a web/socket server for multi-threaded vs async with a colleague, and the async was faster.) for me it is a shit to force into a class.

                                                                                                                    The thing I like about threads is that the flow of data is there and laid out neatly _per thread_, where as to me, async feels like surprise goto. async feels like it accepts a request, and then will at some point at the future either trigger more async, or crap out mixing loads of state from different requests all over the place.

                                                                                                                    To me it feels like a knotted wool bundle, where as threaded/multi-process feels like a freshly wound bobbin.

                                                                                                                    Now, this is all viiiiiibes man, so its subjective.

                                                                                                                    • kurtis_reed 3 hours ago

                                                                                                                      The premise of the article is wrong. Async in Python is popular. I'd expect most new web backends to use it.

                                                                                                                      The article says SQLalchemy added async support in 2023 but actually it was 2020.

                                                                                                                      • MichaelRazum 7 hours ago

                                                                                                                        You can’t just plug and play it. As soon as you introduce async you need to have the runtime loop and so on. Basically the whole architecture needs to be redesigned

                                                                                                                        • whilenot-dev 6 hours ago

                                                                                                                          asyncio has been designed to be as "plug and play" as it gets. I'd discourage it, but one could create async loops wherever one would need them, one separate thread per loop, and adapt the code base in a more granular fashion. Blocking through the GIL will persist, though.

                                                                                                                          For any new app that is mostly IO constraint I'd still encourage the use of asyncio from the beginning.

                                                                                                                          • odyssey7 2 hours ago

                                                                                                                            I remember back when the “Pythonic” philosophy was to make the language accessible.

                                                                                                                            It’s clear that Dr. Frankenstein has been at large and managed to get his hands on Python’s corpse.

                                                                                                                            • kstrauser 11 minutes ago

                                                                                                                              I don’t think that’s fair. Yeah, there is a lot to learn and keep track of. At the same time, it’s an inherently complex problem. From one POV, and async Python program looks a lot like a cooperative multitasking operating system, but with functions instead of processes. It was a lot harder to write well-behaved programs on classic Mac OS than it was on a Commodore 64, but that Mac app was doing an awful lot more than the C64 program was. You couldn’t write them the same way and expect good results, but instead had to go about it a totally different way. It didn’t mean the Mac way was bad, just that it had a lot more inherent complexity.

                                                                                                                          • DrillShopper 6 hours ago

                                                                                                                            It's this - asyncio is a nightmare to add to and get working in a code base not specifically designed for it, and most people aren't going to bother with that. asyncio is not good enough at anything it does to make it worth it to me to design my entire program around it.

                                                                                                                          • taeric 2 hours ago

                                                                                                                            Wouldn't this be like asking why bit packing/flipping isn't more popular in python? In general, it just isn't necessary for the vast majority of programs people are likely to write using python.

                                                                                                                            Which isn't to argue that they did a good or a bad job adding the ability to the language. It just isn't the long pole in performance concerns for most programs.

                                                                                                                            • rdtsc 6 hours ago

                                                                                                                              I never liked async in Python. I feel like it's a bad design pattern, a lot of borrowed from Twisted at the time. I always liked gevent/eventlet based approach and will likely always stick to using that. At the time Go and Elixir/Erlang had green threads (lightweight procs / goroutines) and in general I think that makes for a cleaner code base.

                                                                                                                              • foresto 4 hours ago

                                                                                                                                A little history...

                                                                                                                                During development, asyncio was called tulip. A quick search turns up this talk by Guido:

                                                                                                                                https://www.youtube.com/watch?v=aurOB4qYuFM

                                                                                                                                I seem to recall that Guido was in touch with the author of Twisted at the time, so design ideas from that project may have helped shape asyncio.

                                                                                                                                https://twisted.org/

                                                                                                                                Before asyncio, Python had asyncore, a minimal event loop/callback module. I think it was was introduced in Python 1.5.2, and remained part of the standard library until 3.12.

                                                                                                                                https://docs.python.org/3.11/library/asyncore.html

                                                                                                                                https://docs.python.org/3.11/library/asynchat.html

                                                                                                                                • blibble 4 hours ago

                                                                                                                                  asyncore actually worked well, unlike asyncio

                                                                                                                                  so of course in their infinite wisdom, they removed it

                                                                                                                                • bjt 4 hours ago

                                                                                                                                  I was using gevent to get async benefits in Python 10+ years ago. It's a much nicer programming paradigm than async/await, in my opinion. Now working in Go where the same pattern is built into the language, I'm even more convinced.

                                                                                                                                  • rsyring 6 hours ago

                                                                                                                                    Not too long ago, I read a comment on HN that suggested, due to Python's support for free-threading, async in Python will no longer be needed and will lose out to free-threading due to it's use of "colored" functions. Which seems to align with where this author ends up:

                                                                                                                                    > Because parallelism in Python using threads has always been so limited, the APIs in the standard library are quite rudimentary. I think there is an opportunity to have a task-parallelism API in the standard library once free-threading is stabilized.

                                                                                                                                    > I think in 3.14 the sub-interpreter executor and free-threading features make more parallel and concurrency use cases practical and useful. For those, we don’t need async APIs and it alleviates much of the issues I highlighted in this post.

                                                                                                                                    Armin recently put up a post that goes into those issue in more depth: https://lucumr.pocoo.org/2025/7/26/virtual-threads/

                                                                                                                                    Which lead me to a pre-PEP discussion regarding the possibility of Virtual Threads in Python, which was probably way more than I needed to know but found interesting: https://discuss.python.org/t/add-virtual-threads-to-python/9...

                                                                                                                                    • int_19h 3 hours ago

                                                                                                                                      C# has had free threading all along, yet still saw the need for async as a separate facility.

                                                                                                                                      The same goes for C++, which now has co_await.

                                                                                                                                      • ashf023 6 hours ago

                                                                                                                                        Interesting that very few people in that thread seem to understand Go's model, especially the author of this proposal. If you don't allow preemption, you still have a sort of coloring because most non async functions aren't safe to call in a virtual thread - they may block the executor. If you call C code, you need to swap out stacks and deal with blocking by potentially spawning more OS threads - that's what CGo does. Maybe preemption is harder in Python, but that's not clearly expressed - it's just rejected as obviously unwanted.

                                                                                                                                        Ultimately Python already has function coloring, and libraries are forced into that. This proposal seems poorly thought out, and also too little too late.

                                                                                                                                        • rsyring 5 hours ago

                                                                                                                                          I can't speak to the more technical aspects you bring up b/c I'm not that well versed in the underlying implementations and tradeoffs.

                                                                                                                                          > and also too little too late.

                                                                                                                                          I think it very likely that Python will still be around and popular 10 years from now. Probably 20 years from now. And maybe 30 years from now. I think that's plenty of time for a new and good idea that addresses significant pain points to take root and become a predominant paradigm in the ecosystem.

                                                                                                                                          So I don't agree that it's too little too late. But whether or not a Virtual Threads implementation can/will be developed and be good enough to gain wide adoption, I just can't speak to. If it's possible to create a better devx than async and get multi-core performance and usage, I'm all for the effort.

                                                                                                                                        • seunosewa 5 hours ago

                                                                                                                                          async was the wrong solution to the right problem - improving general performance. Free threading is the prize in an increasingly multi-core CPU world.

                                                                                                                                        • liquidpele 24 minutes ago

                                                                                                                                          Because it’s terrible. People don’t avoid non-terrible things.

                                                                                                                                          • kamikaz1k 7 hours ago

                                                                                                                                            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.

                                                                                                                                            • TZubiri 4 hours ago

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

                                                                                                                                            • tonymet an hour ago

                                                                                                                                              async only helps with io-wait concurrency, but not cpu-bound concurrency.

                                                                                                                                              async is popular in JS because the browser is often waiting on many requests.

                                                                                                                                              command-line tools are commonly computing something. even grep has to process the pattern matching so concurrent IO doesn't help a single-threaded pattern match.

                                                                                                                                              Sure there are applications where async would help a CLI app, but there are fewer than JS.

                                                                                                                                              Plus JS devs love rewriting code very 3 months.

                                                                                                                                              • odyssey7 3 hours ago

                                                                                                                                                Python is ergonomically challenged, so we shouldn’t be surprised when features built on that foundation go unused.

                                                                                                                                                • dapperdrake 7 hours ago

                                                                                                                                                  Python's async is very difficult to use and debug. It seems to get stuck randomly, read like race conditions. And Python cannot work around this nicely with their lambdas only permitting a single expression in their body.

                                                                                                                                                  Not worth the trouble. Shell pipelines are way easier to use. Or simply waiting —no pun intended— for the synchronous to finish.

                                                                                                                                                  • mixmastamyk 7 hours ago

                                                                                                                                                    > lambdas only permitting a single expression

                                                                                                                                                    Use a tuple, maybe walrus, and return the last item[-1].

                                                                                                                                                    • dapperdrake 3 hours ago

                                                                                                                                                      That idea sounds good.

                                                                                                                                                      How do I get variables for not redoing long-running computations that depend on one-another? So, what if the third tuple value depends on the second and the second in turn depends on the first?

                                                                                                                                                      • mixmastamyk 35 minutes ago

                                                                                                                                                        That’s what walrus is for. I have example code but am on a phone.

                                                                                                                                                        • int_19h 3 hours ago

                                                                                                                                                          You can abuse list and sequence comprehensions for this. `for..in` is effectively a variable binding since you can target a freshly created list or a tuple if you need to bind a single value. So:

                                                                                                                                                            [x
                                                                                                                                                             for x in [some_complicated_expression]
                                                                                                                                                             if x > 0
                                                                                                                                                             for y in [x + 1]
                                                                                                                                                             ...
                                                                                                                                                            ][0]
                                                                                                                                                          
                                                                                                                                                          That said, I wouldn't recommend this because of poor readability.
                                                                                                                                                    • tschellenbach 7 hours ago

                                                                                                                                                      Yes, this!. Its a mess, some typing, some async. No standardization/ one way to do things. Literally goes against the original ZEN of python

                                                                                                                                                      "There should be one-- and preferably only one --obvious way to do it : Aim for a single, clear solution to a problem. "

                                                                                                                                                      • aquariusDue 7 hours ago

                                                                                                                                                        Cue the zen of python apologists explaining how we just don't get it and that with enough reframing it'll click.

                                                                                                                                                        Snide remark aside, I actually like the Zen of Python as programming language folklore but in 2025 AD it's kinda crazy to pretend that Python actually adheres to those tenets or whatever you wish to call them, and I'd go as far as to claim that it does a disservice to a language flexible enough for a lot of use cases. There's even someone on YouTube developing a VR game with Python.

                                                                                                                                                        • int_19h 3 hours ago

                                                                                                                                                          It has never been literally true anyway, not even back when it was originally written.

                                                                                                                                                      • alanfranz 6 hours ago

                                                                                                                                                        Much more than 10y. Twisted existed since the 90s. I didn’t read the whole article but I find is strange that it’s not mentioned, ever.

                                                                                                                                                        • lormayna 4 hours ago

                                                                                                                                                          I always considered the ergonomic of async/await not really ergonomical and hard to debug. I really like, indeed, the go approach: using goroutines, channels and waitgroups is powerful and easy.

                                                                                                                                                          • game_the0ry 2 hours ago

                                                                                                                                                            I will take a couple stabs:

                                                                                                                                                            - Async is a legitimately hard to get if you are just starting to learn it, which is probably why its isn't more popular in the python community.

                                                                                                                                                            - If you need async, that implies you need hi I/O performance. At that point, you probably should have picked a more performant language + runtime (Java, Node), bc use case should dictate tooling.

                                                                                                                                                            - It's not enough to make a language + web framework to be async -- the DB drivers need to be async too (author mentions sqlalechemy got async support in 2023 and django orm is a WIP).

                                                                                                                                                            I like python, but not bc its async or multi-threaded. I like it bc when I use it, I know I do not have to worry about those things and the new set of problems I have to handle when I do.

                                                                                                                                                            For the i/o and multi-threaded perf, give me java and node (maybe erlang/elixir if I am feeling extra spicy). For the fast and easy scripting, with massive community of open source of talent and high quality libraries (including the vast majority of web app slop), give me python.

                                                                                                                                                            • hoppp 2 hours ago

                                                                                                                                                              To be frank someone who picks python is not doing it because they want the best performance.

                                                                                                                                                              Its either because its the only language they know or they just don't really care about performance and want to finish the project fast.

                                                                                                                                                              • game_the0ry 2 hours ago

                                                                                                                                                                Agreed, bc I have been that "someone."

                                                                                                                                                                And there is nothing wrong with that. In fact, this should be the norm.

                                                                                                                                                            • nromiun 6 hours ago

                                                                                                                                                              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 errors instead of deadlocks everywhere.

                                                                                                                                                              Async works in JS so well because the entire language is designed for it, instead of async being just bolted on. You can't even run plain `sleep` to block, you need setTimeout.

                                                                                                                                                              • DanielHB 4 hours ago

                                                                                                                                                                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.

                                                                                                                                                              • giancarlostoro 7 hours ago

                                                                                                                                                                I think part of it is historical. WSGI has been around a while before async became relevant. The industry now has had ASGI for a while, but if your WSGI deployed web application doesn't need to squeeze out all the juice it can with async, you might not be phased by not using it or bothered at all.

                                                                                                                                                                Reminds me of how long it took some to go from Python 2 to Python 3.

                                                                                                                                                                • ayaros 3 hours ago

                                                                                                                                                                  I love JS's async. I don't know how anyone ever did anything useful in the language before it was introduced. I think something between a third and half of the functions and members in LisaGUI are probably async functions at this point.

                                                                                                                                                                  • throwawayffffas 3 hours ago

                                                                                                                                                                    The function coloring is a non starter for me.

                                                                                                                                                                    I would just rather write JS where everything is async by default.

                                                                                                                                                                    • IshKebab 3 hours ago

                                                                                                                                                                      Everything is not async by default in JS.

                                                                                                                                                                      • fzzzy 2 hours ago

                                                                                                                                                                        I think what they mean is that there are no blocking functions in the standard library except alert, prompt, and confirm. ( are there any others?)

                                                                                                                                                                        • throwawayffffas 3 hours ago

                                                                                                                                                                          I mean everything is running on the runloop, async/await, promises, and callbacks are different flavors of syntactic sugar for the same underlying thing.

                                                                                                                                                                          In JS you can do:

                                                                                                                                                                             async function foo(){...}
                                                                                                                                                                             function bar(){foo().then(...);}
                                                                                                                                                                          
                                                                                                                                                                          In python though async and sync code runs in a fundamentally different way as far as I understand it.
                                                                                                                                                                          • IshKebab 3 hours ago

                                                                                                                                                                            I'm not too familiar with Python async. The only time I used it was to get stderr and stdout out of a subprocess.run() separately. I think anyone using it for performance reasons is insane and should just switch to a more performant language.

                                                                                                                                                                            Anyway I think the main difference is that in Python you control the event loop whereas in JS there's one fixed event loop and you have no choice about it.

                                                                                                                                                                      • didip 2 hours ago

                                                                                                                                                                        It would have been a lot more popular if it has a shim that lets it pretend to be a regular thread. Folks don't like to perform a lot of rewrites.

                                                                                                                                                                        • fulafel 6 hours ago

                                                                                                                                                                          I think this is for the best. We don't want to end up like Rust. The complexity tradeoff suits Python's sweet spot even less (much less).

                                                                                                                                                                          • Meneth 6 hours ago

                                                                                                                                                                            KeyboardInterrupt (Ctrl+C) has been a problem wherever I've used python async. It should just work out of the box.

                                                                                                                                                                            • rcarmo 7 hours ago

                                                                                                                                                                              I've had no real issues with async, although I primarily use libraries like aiohttp and aiosqlite and even write my own helpers (https://github.com/rcarmo/aioazstorage is a good example).

                                                                                                                                                                              The vast majority of the Python code I wrote in the last 5-6 years uses asyncio, and most of the complaints I see about it (hard to debug, getting stuck, etc.) were -- at least in my case -- because there were some other libraries doing unexpected things (like threading or hard sleep()).

                                                                                                                                                                              Coming from a networking background, the way I can deal with I/O has been massively simplified, and coroutines are quite useful.

                                                                                                                                                                              But as always in HN, I'm prepared for that to be an unpopular opinion.

                                                                                                                                                                              • JackSlateur 7 hours ago

                                                                                                                                                                                I share your experience

                                                                                                                                                                                asyncio is easier than threads or multiprocess: less locking issue, easier to run small chunks of code in // (easier to await something than to create a thread that run some method)

                                                                                                                                                                              • OhMeadhbh 4 hours ago

                                                                                                                                                                                I'm not the biggest Python fan, but when I was forced to use it using async disabled a bunch of things... like the debugger. Not a fan.

                                                                                                                                                                                • Areading314 7 hours ago

                                                                                                                                                                                  I think explicit management of the event loop and the associated potential for grievous bugs has a lot to do with it.

                                                                                                                                                                                  • jpgvm 3 hours ago

                                                                                                                                                                                    Because they chose the wrong API (well more correctly created a new, worse one).

                                                                                                                                                                                    In order to appease the various flavours they mixed and matched stuff from Tornado, gevent, etc.

                                                                                                                                                                                    They should have stuck with the most seamless of those (gevent) and instead of having it monkey-patch the runtime go the Java VirtualThread route and natively yield in all the I/O APIs.

                                                                                                                                                                                    This would have given a Go-esque ease of use and likely would have been immensely more popular.

                                                                                                                                                                                    • ketchupdebugger 7 hours ago

                                                                                                                                                                                      The two api issue basically means async is not backwards compatible. You can't just squeeze some async into an existing code base, You'd need new functions, libraries etc. You'd basically need to rewrite the entire codebase in async to see an ounce of perf improvements.

                                                                                                                                                                                      • the__alchemist 5 hours ago

                                                                                                                                                                                        The barrier it places in Rust's lib ecosystem is unpleasant; I'm glad it hasn't taken off in Python. I have written too many rust libs because the existing ones forced your code to be Async.

                                                                                                                                                                                        • bmandale 7 hours ago

                                                                                                                                                                                          I don't like the idea of launching a whole thread for every concurrent task I want to do. But holy hell is it so much easier than figuring out how tf async works. If I wanted something super performant I wouldn't be using python in the first place.

                                                                                                                                                                                          • dekhn 7 hours ago

                                                                                                                                                                                            It added intrusive- codebase-wide- functionality that more or less could have been done with other (thread-based) approaches.

                                                                                                                                                                                            AWSCLI was broken for over a year- we had to do a ton of work to deal with the various packaging issues.

                                                                                                                                                                                            Don't break userspace.

                                                                                                                                                                                            • AtlasBarfed 3 hours ago

                                                                                                                                                                                              Why was awscli written in python? Bad decision to begin with.

                                                                                                                                                                                              Hey! We have a product that we clearly want to release worldwide. Let's build it on something that doesn't have Unicode. Or any real threading. And is slow as hell.

                                                                                                                                                                                              You picked a platform that was going to have to break user space.

                                                                                                                                                                                              At least it wasn't JavaScript

                                                                                                                                                                                              • fzzzy 2 hours ago

                                                                                                                                                                                                Doesn’t have Unicode? What the heck?

                                                                                                                                                                                            • tripletpeaks 7 hours ago

                                                                                                                                                                                              It’s probably related to the fact that when they added “await” to JavaScript, it seemed to become the most popular keyword in the language overnight, just comical amounts of it in the average new JavaScript file in the wild.

                                                                                                                                                                                              • lelanthran 3 hours ago

                                                                                                                                                                                                Quite a lot of my js functions don't await; instead I simply return the promise and let the caller `await` or more often attach a `then` as they see fit.

                                                                                                                                                                                                The default linter in Vs Code keeps marking those functions with warnings though. Says I should mark them as async

                                                                                                                                                                                              • dec0dedab0de 7 hours ago

                                                                                                                                                                                                It's had async way longer than 10 years. multi-threading/processing, celery, twisted, others I can't remember.

                                                                                                                                                                                                Asyncio means learning different syntax that buys me nothing over the existing tools. Why would I bother?

                                                                                                                                                                                                • baq 7 hours ago

                                                                                                                                                                                                  async, parallelism, concurrency, why not all three? JS, the canonical async (at least today) language, has had neither parallelism nor concurrency primitives for a good decade or so after its inception.

                                                                                                                                                                                                  I personally blame low async adoption in Python on 1) general reduction in its popularity vs Typescript+node, which is driven by the desire to have a single stack on the frontend and backend, not by bad or good async implementations in Python (see also: Rails, once the poster child of the Web, now nearly forgotten) 2) lack of good async stdlib. parallelism and concurrency are distant thirds.

                                                                                                                                                                                                  • dragonwriter 7 hours ago

                                                                                                                                                                                                    > async, parallelism, concurrency, why not all three?

                                                                                                                                                                                                    async is a concurrency mechanism.

                                                                                                                                                                                                    • JackSlateur 7 hours ago

                                                                                                                                                                                                      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

                                                                                                                                                                                                      • DanielHB 4 hours ago

                                                                                                                                                                                                        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)

                                                                                                                                                                                                  • taude 7 hours ago

                                                                                                                                                                                                    Use an appropriate language and runtime for the right tool/workload. There's better languages and runtimes to use that have better native concurrency built in.

                                                                                                                                                                                                    • fullstop 7 hours ago

                                                                                                                                                                                                      Exceptions are difficult to deal with. Also, while they've had async for 10 years it has changed quite a bit from the initial incarnation.

                                                                                                                                                                                                      • blibble 4 hours ago

                                                                                                                                                                                                        there are some Exception situations that are almost completely impossible to deal with

                                                                                                                                                                                                        like guaranteeing a close() inside a finally

                                                                                                                                                                                                        asyncio is a terrible, terrible library

                                                                                                                                                                                                      • JodieBenitez 6 hours ago

                                                                                                                                                                                                        Why isn't it more popular ? Well, replacing libs and functions with async versions is not fun.

                                                                                                                                                                                                        • adfm 7 hours ago

                                                                                                                                                                                                          Twisted?

                                                                                                                                                                                                          • lstodd 7 hours ago

                                                                                                                                                                                                            And Tornado. Please don't remind me of those horrors.

                                                                                                                                                                                                          • omnicognate 5 hours ago

                                                                                                                                                                                                            For a counter-opinion that isn't getting stated much here, I think:

                                                                                                                                                                                                            * Asyncio is pretty good, and is usually the best choice for non-blocking I/O in python these days.

                                                                                                                                                                                                            * Asyncio doesn't add multi-core scaling to python. It's not a replacement for threads and doesn't lift the GIL-imposed scaling limitations. If these things are what you're after from asyncio you'll be disappointed, but they're not what it's trying to add and not adding them doesn't make it a failure.

                                                                                                                                                                                                            * "Coloured functions" is a nonsense argument and that article made the whole world slightly more dumb.

                                                                                                                                                                                                            * The GIL is part of the reason for python's success. I hope nogil either somehow manages to succeed without compromising the benefits the GIL has brought (I'll be amazed if that happens) or fails entirely. Languages are tools and every tool in your toolbox doesn't have to eventually turn into a drill. If your use case requires in-process parallelisation of interpreted CPU-bound workloads across multiple cores, python is just the wrong thing to use.

                                                                                                                                                                                                            * It is indeed extremely annoying that we don't have async file access yet. I hope we get it soon.

                                                                                                                                                                                                            • silverwind 7 hours ago

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

                                                                                                                                                                                                              • rcarmo 7 hours ago

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

                                                                                                                                                                                                                • operator-name 4 hours ago

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

                                                                                                                                                                                                              • northisup 7 hours ago

                                                                                                                                                                                                                because two colors of functions suuuuuuuuuuks to deal with

                                                                                                                                                                                                                • Analemma_ 7 hours ago

                                                                                                                                                                                                                  Doesn't really explain why async/await are hugely popular in C#, JavaScript, etc. but didn't take off in Python.

                                                                                                                                                                                                                  • topspin 3 hours ago

                                                                                                                                                                                                                    I'd explain your cases this way:

                                                                                                                                                                                                                    C# has a dictator with a budget: Microsoft integrated async into C# in a formal way, with 5.0, including standard libs, debugging, docs, samples, clear guidance going forward, etc. What holes there were were dealt with in an orderly and timely manner.

                                                                                                                                                                                                                    JavaScript actually had a pretty messy start with async, with divergent conventions and techniques. Ultimately this got smoothed out with language additions, but it wasn't all that wonderful in the early days. Also, JavaScript started from a simpler place (single-threaded event loop) that never had "fork" and threads and all that comes with those, so there was less legacy to accommodate and fewer problems to overcome.

                                                                                                                                                                                                                    Python had a vast base of existing non-async software chock full of blocking code, plus an incomplete and haphazard concurrency evolution. There are several legacy concurrency solutions in Python, most still in use today. Python async is still competing and conflicting with it all. Not unlike the Python 2->3 transition.

                                                                                                                                                                                                                • 6510 3 hours ago

                                                                                                                                                                                                                  I've always felt like there is some hidden clue in music trackers. They program the music as spaghetti code with unlimited channel running neatly along the same line numbers.

                                                                                                                                                                                                                  • th0ma5 6 hours ago

                                                                                                                                                                                                                    I adopted just the Clojure style of thinking in terms of immutable copies and it seems easier to move between synch and asynch conceptually as needed, although Clojure has some asynch parallelism automatically due to this paradigm as well.

                                                                                                                                                                                                                    • whalesalad 7 hours ago

                                                                                                                                                                                                                      I adopted gevent/greenlets pretty early on and it has always felt better than asyncio, monkey-patching aside.

                                                                                                                                                                                                                      • lysace 7 hours ago

                                                                                                                                                                                                                        Because it takes a a lot of reading/studying/experimentation to get things right.

                                                                                                                                                                                                                        I'm personally halfway through that journey (having spent like 4h reading docs/learning, on top of the development). I suspect it could have been designed in such a way so that it's less trivially easy to mess up.

                                                                                                                                                                                                                        • andrewstuart 5 hours ago

                                                                                                                                                                                                                          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.

                                                                                                                                                                                                                          • kamikaz1k 4 hours ago

                                                                                                                                                                                                                            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

                                                                                                                                                                                                                          • lstodd 7 hours ago

                                                                                                                                                                                                                            idk stackless dates back to 2005 at least, most likely earlier.

                                                                                                                                                                                                                            greenlet which is sort of minimal stackless .. before 2008

                                                                                                                                                                                                                            pycoev which is on one hand greenlets without memmove()s, on the other hand sort of io-scheduled m:n threading I wrote myself in 2009.

                                                                                                                                                                                                                            so, at least idk, 20 years?

                                                                                                                                                                                                                            It was first needed. Then 10 years passed, people got around to pushing it through the process aaand by the time it was done it was already not needed. so it all stalled. Same with Rust.

                                                                                                                                                                                                                            Nowadays server-side async is handled very differently. And client-side is dominated by that abomination called JS.

                                                                                                                                                                                                                            • fulafel 5 hours ago

                                                                                                                                                                                                                              Also back then multicore wasn't as prevalent, it made sense to multiplex a zillion things onto one CPU process. Whereas now servers have hundreds of cores / SMT vCPUs [1] and running a lot of processes makes much more sense.

                                                                                                                                                                                                                              [1] https://www.tomshardware.com/pc-components/cpus/amd-announce...

                                                                                                                                                                                                                              • toolslive 6 hours ago

                                                                                                                                                                                                                                I never understood why stackless wasn't more popular. It was rather nice, clean and performant (well, it's still python but it provide(d) proper concurrency)

                                                                                                                                                                                                                                • lstodd 5 hours ago

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

                                                                                                                                                                                                                                  • ack_complete 5 hours ago

                                                                                                                                                                                                                                    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, and it only made sense if you knew that OutputDebugString() is implemented internally by throwing a continuable exception.

                                                                                                                                                                                                                                    The more significant problem was that Stackless was a separate distribution. Every time CPython updated, there would be a delay until Stackless updated, and tooling like Python IDEs varied in whether they supported Stackless.

                                                                                                                                                                                                                                    • lstodd 4 hours ago

                                                                                                                                                                                                                                      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...

                                                                                                                                                                                                                              • OutOfHere 7 hours ago

                                                                                                                                                                                                                                With the newest Python, I can use no-gil, so my threads automatically use multiple cores. With asyncio, even under no-gil, unless I use a base layer that offers parallelism, I am stuck to a single core by default, which doesn't make any sense in a multicore world. In contrast, with Rust's async, there is no such limitation.

                                                                                                                                                                                                                                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).

                                                                                                                                                                                                                              • cyberax 6 hours ago

                                                                                                                                                                                                                                To add to this, async in Python is also plain buggy. For example, uvicorn is the most popular FastAPI server, and it leaks contexts across requests in the default installation.

                                                                                                                                                                                                                                The bug has been open for 2 years, with zero fucks given. The workaround is "just use libuv": https://github.com/encode/uvicorn/issues/2167

                                                                                                                                                                                                                                I've seen other such cases, and I just gave up on trying to use async.

                                                                                                                                                                                                                                • cyberax 2 hours ago

                                                                                                                                                                                                                                  Another thing: the lack of JIT. NodeJS is also single-threaded, but it's _fast_ because of one of the best JITs in the industry. So you can feasibly run hundreds if not thousands requests per second on one core.

                                                                                                                                                                                                                                  If you try to do that with Python, you get performance that is not acceptable. So why even bother?

                                                                                                                                                                                                                                  • TZubiri 4 hours ago

                                                                                                                                                                                                                                    Because I don't need it.

                                                                                                                                                                                                                                    When I need to do concurrent stuff I either use fork to multiprocess or use the threading library, no import necessary, couple of lines of code, no need to make specialized code with await keywords and stuff.

                                                                                                                                                                                                                                    This line made me question myself though:

                                                                                                                                                                                                                                    "Then Flask is and probably always will be synchronous (Quart is an async alternative with similar APIs)."

                                                                                                                                                                                                                                    I use flask, and I literally spent the last hour questioning whether I was an idiot and needed to dm my previous clients asking them to fix my code. I'm wondering how my apps passed stress tests of thousands of concurrent users, maybe I did the tests wrong?

                                                                                                                                                                                                                                    Chatgpt says

                                                                                                                                                                                                                                    "s flask asynchronous? ChatGPT said:

                                                                                                                                                                                                                                    Flask itself is not asynchronous. It is a WSGI-based framework, which means it is synchronous by design — it handles one request at a time per worker. Each request is processed sequentially, and concurrency is typically achieved by running multiple worker processes"

                                                                                                                                                                                                                                    Oh shit, I didn't use gunicorn, I just run the python script raw. I'm an idiot. Let's write a test server that sleeps for 1 second before responding to a request:

                                                                                                                                                                                                                                    " import flask import requests import time app = flask.Flask("test")

                                                                                                                                                                                                                                    @app.route("/") def hi(): time.sleep(1) #requests.get("https://google.com") return "Hello, World!"

                                                                                                                                                                                                                                    app.run("0.0.0.0",8088) "

                                                                                                                                                                                                                                    This should block for like 25ms, if 50 concurrent users ask for this resource, there will be an average 500ms of extra latency!

                                                                                                                                                                                                                                    And a Test client that does 50 calls at once, will it take 50 seconds?:

                                                                                                                                                                                                                                    "import threading import requests

                                                                                                                                                                                                                                    URL = "http://127.0.0.1:8088/"

                                                                                                                                                                                                                                    def make_request(i): try: print("req") response = requests.get(URL) print("res") except: print("fail")

                                                                                                                                                                                                                                    threads = []

                                                                                                                                                                                                                                    for i in range(5): t = threading.Thread(target=make_request, args=(i,)) threads.append(t) t.start()

                                                                                                                                                                                                                                    for t in threads: t.join()

                                                                                                                                                                                                                                    print("All requests completed")

                                                                                                                                                                                                                                    "

                                                                                                                                                                                                                                    Then we run with time binary in linux:

                                                                                                                                                                                                                                    >time python3 client.py

                                                                                                                                                                                                                                    All requests completed

                                                                                                                                                                                                                                    real 0m1.216s user 0m0.203s sys 0m0.039s

                                                                                                                                                                                                                                    Ok, turn off the alarms, Flask is fine.

                                                                                                                                                                                                                                    I'm not sure what's going on with async, but the only experience I had with it was a junior dev that came from writing horrible node apps with react and nest (his frontend connected to a supabase db directly with credentials exposed, even if there was a node backend).

                                                                                                                                                                                                                                    He wanted to pivot to python because that's what I used and I had good results, so he installed Quartz instead of Flask, and he was writing Node like code in python, and it was of course a mess.

                                                                                                                                                                                                                                    Not saying that it's always going to be a mess, but you are better off learning the native way of a language instead of trying to shoehorn other abstractions and claiming that the way it is done in python is inefficient, it's one of the most popular languages in the world, these are massively used libraries, it's unlikely that "something is terribly wrong". It's more of a meme that python is slow.

                                                                                                                                                                                                                                    What async is, is an alternative and supposedly cleaner abstraction to do multithreading. What ends up happening is that people use it without understanding multithreading and operating systems in general, they just think that they need to use it to get parallelism.

                                                                                                                                                                                                                                    There's 15 solutions to do parallelism, 1 is the native, vanilla solution (threading library), then there's 3 additional experimental ways in the standard library or futures library, and 11 solutions that you need to pip install. Newbies ask chatgpt or see a stackoverflow thread (or come from node), and they have a 1 in 15 chance of using the regular solution that newbies should be using, because they can't distinguish the wheat from the chaffe.

                                                                                                                                                                                                                                    OP might have suffered from this and even believed that this 15th "async" way to do concurrency was the only way, and is judging python's concurrency by this feature. OP maybe believes that python is just now getting multithreading support? That we are all cavemen running toy applications that server 2 or 3 users? Word to the wise, focus on features that have existed on early versions like python2 BEFORE you focus on features that are being introduced in the later versions like 3.14, this in general, you should first learn how a UNIX machine from the 90s did its thing before you learn the kubernetes spark majiggy

                                                                                                                                                                                                                                    • ilaksh 7 hours ago

                                                                                                                                                                                                                                      There is a fundamental misunderstanding about popularity. People think that popularity is directly related to merit or rationality.

                                                                                                                                                                                                                                      Technical things are largely popular for the same reason non-technical things are popular: trends. In other words, they are popular because other people perceive them to be popular. Humans are herd animals.

                                                                                                                                                                                                                                      async is harder and associated with Node.js/JavaScript which probably makes it uncool for a certain influential python subculture.

                                                                                                                                                                                                                                      But actually Fast API has basically taken over and now I think people should recognize that means async IS popular in python at this point.