I need to run dozens of computationally intensive CPU-bound parallel tasks. Currently I do it using joblib
delayed
and Parallel
:
resultTuples = Parallel(n_jobs=-1, prefer="processes")(delayed(RunSingleTask)(*p) for p in run_params)
It works fine but I have to wait until all tasks have finished to get the list of results and process them after. And I’d like to get the result of each finished task right after it is ready to process it.
Tasks have no IO, so I don’t see any purpose in using async stuff like:
for first_completed in asyncio.as_completed(tasks):
...
So how can I do this?