News for hackers. Stuff that matters.
Re:Python Asyncio: The Complete Guide by quietbritishjim on Thursday November 10, 2022 @10:39AM (#33548003)
Not complete - doesn't include Task Groups [1]

In fairness they were only included in asyncio as of Python 3.11, which was released a couple of weeks ago.

These were an idea originally from Trio [2] where they're called "nurseries" instead of "task groups". My view is that you're better off using Trio, or at least anyio [3] which gives a Trio-like interface to asyncio. One particularly nice thing about Trio (and anyio) is that there's no way to spawn background tasks except to use task groups i.e. there's no analogue of asyncio's create_task() function. That is good because it guarantees that no task is ever left accidentally running in the background and no exception left silently uncaught.

[1] https://docs.python.org/3/library/asyncio-task.html#task-gro...

[2] https://github.com/python-trio/trio

[3] https://anyio.readthedocs.io/en/latest/

Re:Python Asyncio: The Complete Guide by dang on Thursday November 10, 2022 @01:42PM (#33551130)
Ok, we've taken completeness out of the title above.
Re:Python Asyncio: The Complete Guide by Steltek on Thursday November 10, 2022 @02:10PM (#33551498)
Python, more than other languages, ends up being used in utility scripts on end user devices, where you'll find just about everything. Python's async seems to still have a large swing in available features. Unlike async methods in other languages, semi-serious dabbling in it just for fun is courting a lot of headaches later.
Re:Python Asyncio: The Complete Guide by throwaway81523 on Thursday November 10, 2022 @03:39PM (#33552966)
I have such a feeling of tragedy about Python. I wish it had migrated to BEAM or implemented something similar, instead of growing all this async stuff. Whenever I see anything about Python asyncio, I'm reminded of gar1t's hilarious but NSFW rant about node.js, https://www.youtube.com/watch?v=bzkRVzciAZg . Content warning: lots of swearing, mostly near the end.
Re:Python Asyncio: The Complete Guide by rogers12 on Thursday November 10, 2022 @04:20PM (#33553541)
That's a blast from the past. Incredible that 10 years ago people thought using a thread per request is a good idea because anything else is too hard.
Re:Python Asyncio: The Complete Guide by icedchai on Thursday November 10, 2022 @06:50PM (#33555382)
I'd argue that thread-per-request is even a better idea now, given the massive number of cores and memory in modern servers.
Re:Python Asyncio: The Complete Guide by mrfox321 on Friday November 11, 2022 @12:17AM (#33557543)
Hybrid?

Request passed to a thread pool. Each thread is juggling coroutines representing in flight requests

Re:Python Asyncio: The Complete Guide by icedchai on Friday November 11, 2022 @04:55PM (#33567414)
Is that worth the complexity? I like the way Go does it. The runtime is managing the actual threading and async IO as it schedules go routines, but to the programmer it all looks like normal synchronous code.
Re:Python Asyncio: The Complete Guide by throwaway81523 on Thursday November 10, 2022 @09:32PM (#33556663)
BEAM has user level processes and can run millions of them in a not too huge VM.
Re:Python Asyncio: The Complete Guide by gpderetta on Friday November 11, 2022 @05:04AM (#33558891)
thread per request doesn't imply kernel threads. And I'm pretty sure even a kernel thread per request in a faster language is going to be better than asincio in python.