I have a function called run_3_processes
, which spawns 3 processes (duh) using multiprocessing.pool.apply
, waits for their results and processes these results and returns a single result.
I have another function called run_3_processes_3_times
, which should run run_3_processes
3 times in parallel, wait for all of them to return and then process all their results.
things I tried:
- using a process pool for
run_3_processes_3_times
- turns out this is complicated because of Python Process Pool non-daemonic? - rewriting the entire applicative code to spawn 9 processes with the same pool - this really convoluted my code and breaks encapsulation
- using a
threadpool.apply
forrun_3_processes_3_times
- for some reason this makes it runs serially, not in parallel - is it because theapply
inrun_3_processes
blocks the GIL?
I'm sure there's a one-liner solution I'm missing... thanks!