jztools.parallelization.selector#

Programatic/environment variable-based selection of thread-based parallelization, process-based parallelization, or mock parallelization.

Module Attributes

JZTOOLS_MAX_PARTYPE

Maximum parallelization type returned by Parallelizer or PoolWorker.

Functions

Parallelizer(preferred_partype, **kwargs)

Returns a runtime-determined parallelizer.

PoolExecutor(preferred_partype, **kwargs)

Returns a runtime-determined pool executor.

jztools.parallelization.selector.JZTOOLS_MAX_PARTYPE = 'PROCESS'#

Maximum parallelization type returned by Parallelizer or PoolWorker. Parallelization types are assumed to have the following increasing order: MOCK, THREAD, PROCESS. Setting a max order of MOCK will change all requested types to MOCK. The value of this variable is set from the eponymous environment variable JZTOOLS_MAX_PARTYPE.

jztools.parallelization.selector.Parallelizer(preferred_partype, **kwargs)#

Returns a runtime-determined parallelizer. The paralleliztion type is determined by preferred_partype and the maximum allowable parallelization type PBLIG_MAX_PARTYPE.

See MockParallelizer, ThreadParallelizer, or ProcessParallelizer.

Parameters:
  • preferred_partype – One of 'MOCK', 'THREAD', 'PROCESS'. the type of parallelizer returned will be the mininum of this value and JZTOOLS_MAX_PARTYPE.

  • kwargs – Extra arguments to pass to the requested parallelizer class.

jztools.parallelization.selector.PoolExecutor(preferred_partype, **kwargs)#

Returns a runtime-determined pool executor. The paralleliztion type is determined by preferred_partype and the maximum allowable parallelization type PBLIG_MAX_PARTYPE.

Parameters:
  • preferred_partype(See the corresponding parameter in Parallelizer )

  • kwargs – Extra arguments to pass to the requested parallelizer class. See MockPoolExecutor, ThreadPoolExecutor, or ProcessPoolExecutor.