Skip to content

Instantly share code, notes, and snippets.

@ThomLecha
ThomLecha / multiProcess.py
Last active April 18, 2024 21:28
Easy-to-use Python module for executing functions in parallel with joblib
from joblib import Parallel, delayed
import multiprocessing
import warnings
DEDICATED_CORE_NUMBER = max(multiprocessing.cpu_count() - 2, 1)
def multiProcess(f, argumentsList, coreNumber=DEDICATED_CORE_NUMBER, prt=1):
"""Takes a function, a list of parameter sets for the function, and a number of cores to use as parameters.
Executes the function in parallel across all parameter sets (using 'coreNumber' cores)
Returns the list of function returns.