tfep.utils.parallel.ProcessPoolStrategy

class tfep.utils.parallel.ProcessPoolStrategy(pool)[source]

Bases: ParallelizationStrategy

Parallelization over a pool of processes using Pool.starmap.

Parameters:

pool (multiprocessing.Pool) – The pool of processes to use to map the arguments.

__init__(pool)[source]

Methods

__init__(pool)

run(func, args)

Parallelize the function over the arguments.

run(func, args)[source]

Parallelize the function over the arguments.

Parameters:
  • func (Callable) – The function to parallelize over the arguments.

  • args (Iterable) – The arguments to distribute across parallel executions of the function. args[i] are the arguments of the i-th execution, and they are passed to the function as func(*args[i]).

Returns:

resultsresults[i] is the return value of the function called with args[i].

Return type:

List