elephant.parallel.ProcessPoolExecutor

class elephant.parallel.ProcessPoolExecutor(max_workers=None)[source]

The wrapper of Python built-in concurrent.futures.ProcessPoolExecutor class.

ProcessPoolExecutor is recommended to use if you have one physical machine (laptop or PC).

Parameters:
max_workersint or None

The maximum number of processes that can be used to execute the given calls. If None or not given then as many worker processes will be created as the machine has processors. Default: None

Methods

__init__([max_workers]) Initialize self.
execute(handler, args_iterate, **kwargs) Executes the queue of [handler(arg, **kwargs) for arg in args_iterate] in multiple processes within one machine (ProcessPoolExecutor) or multiple nodes (MPIPoolExecutor and MPICommExecutor).
execute(handler, args_iterate, **kwargs)[source]

Executes the queue of [handler(arg, **kwargs) for arg in args_iterate] in multiple processes within one machine (ProcessPoolExecutor) or multiple nodes (MPIPoolExecutor and MPICommExecutor).

Parameters:
handlercallable

A function to be executed for each argument in args_iterate.

args_iteratelist

A list of (different) values of the first argument of the handler function.

kwargs

Additional key arguments to handler.

Returns:
resultslist

The result of applying the handler for each arg in the args_iterate. The i-th item of the resulting list corresponds to args_iterate[i] (the order is preserved).