by noident on 9/28/2024, 8:27:03 PM
by game_the0ry on 10/3/2024, 2:42:58 PM
I am fairly confident I will get some down votes for this, but here goes...
When I am trying to solve a technical problem, the problem is going to dictate my choice of tooling.
If I am doing some fast scripting or I need to write some glue code, python is my go-to. But if I have a need for resource efficiency, multi threading, non-blocking async i/o, and/or hi performance, I would not consider python - I would probably use JVM over the best python option.
Don't get me wrong, I think its a worthwhile effort to explore this effort, and I certainly do not think its a wasted effort (quite the opposite, this gets my up vote) I just don't think I would ever use it if I had use case for perf and resource efficiency.
by m11a on 10/3/2024, 1:25:47 PM
Perhaps a silly question, but should an event loop actually be multithreaded?
My understanding was that tasks in an event loop should yield after they dispatch IO tasks, which means the event loop should be CPU-bound right? If so, multithreading should not help much in theory?
by quotemstr on 9/28/2024, 8:21:58 PM
At that point, why bother with asyncio? What we really want is something like Java virtual threads, something that doesn't have a code color.
> It got me wondering if it was actually possible to make Python’s async event loop work with multiple threads.
There is built-in support for this. Take a look at loop.run_in_executor. You can await something scheduled in a separate Thread/ProcessPoolExecutor.
Granted, this is different than making the async library end-to-end multi-threaded as you seem to be trying to do, but it does seem worth mentioning in this context. You _can_ have async and multiple threads at the same time!