Re:Free-threaded CPython is ready to experiment with
by LegionMammal978 on Friday July 12, 2024 @08:28PM
(#40950721)
Rust's version of async/await is the same in that respect, where futures don't do anything until you poll them (e.g., by awaiting them): if you want something to just start right away, you have to call out to the executor you're using, and get it to spawn a new task for it.
Though to be fair, people complain about this in Rust as well. I can't comment much on it myself, since I haven't had any need for concurrent workloads that Rayon (a basic thread-pool library with work stealing) can't handle.
Re:Free-threaded CPython is ready to experiment with
by pests on Friday July 12, 2024 @10:01PM
(#40951175)
That is a common split in language design decisions. I think the argument for the python-style where you have to drive it to begin is more useful as you can always just start it immediately but also let's you delay computation or pass it around similar to a Haskell thunk.
Re:Free-threaded CPython is ready to experiment with
by kristjansson on Saturday July 13, 2024 @02:13AM
(#40952188)
There is also https://docs.python.org/3/library/asyncio-task.html#eager-ta... if you want your task to start on creation.
To make background jobs, I've used the class-based version to start a thread, then the magic method that's called on await simply joins the thread. Which is a lot of boilerplate to get a little closer to how async works in (at least) js and c#.