News for hackers. Stuff that matters.
Re:How to use a Python multiprocessing module by kastden on Thursday July 27, 2023 @07:49PM (#36901602)
Check out ProcessPoolExecutor [0] (and ThreadPoolExecutor) too for an easy way to spin up a bunch of tasks and wait for them to complete.

[0] https://docs.python.org/3/library/concurrent.futures.html#pr...

Re:How to use a Python multiprocessing module by gpderetta on Friday July 28, 2023 @06:48AM (#36905088)
Coincidence: I literally read that doc-page and wrote some ThreadPoolExecutor code 5 minutes ago to workaround the lack of a specific async operation in asyncio.
Re:How to use a Python multiprocessing module by evomassiny on Friday July 28, 2023 @08:17AM (#36905768)
Agreed ! Plus, the ability submit a bunch of tasks, and to block until _one_ task completed (akin to `epoll_wait` of tokio's `select`) makes it quite useful. I don't know of a use case or `mutiprocessing.Pool` which is not covered by `concurrent.futures.ProcessPoolExecutor`; so I wonder why both exist
Re:How to use a Python multiprocessing module by hangonhn on Friday July 28, 2023 @11:37AM (#36908459)
In general, the Executor or even Queue abstractions are much better and safer ways of doing multithreading and multiprocessing. These days, I rarely ever directly create threads. It's fine for situations when you must but parallelizing work can usually be done better, safer, and easier with executors.