hyperspy.utils.parallel_pool module

class hyperspy.utils.parallel_pool.ParallelPool(num_workers=None, ipython_kwargs=None, ipyparallel=None)

Bases: object

Creates a ParallelPool by either looking for a ipyparallel client and then creating a load_balanced_view, or by creating a multiprocessing pool

setup()

sets up the requested pool

sleep()

sleeps for the requested (or timeout) time

has_pool

Bool – Boolean if the pool is available and active.

pool

{ipyparallel.load_balanced_view, multiprocessing.Pool} – The pool object.

ipython_kwargs

dict – The dictionary with Ipyparallel connection arguments.

timeout

float – Timeout for either pool when waiting for results.

num_workers

int – The number of workers actually created (may be less than requested, but can’t be more).

timestep

float – Can be used as “ticks” to adjust CPU load when building upon this class.

is_ipyparallel

bool – If the pool is ipyparallel-based

is_multiprocessing

bool – If the pool is multiprocessing-based

has_pool

Returns bool if the pool is ready and set-up

is_ipyparallel

Returns bool if the pool is ipyparallel-based

is_multiprocessing

Returns bool if the pool is multiprocessing-based

setup(ipyparallel=None)

Sets up the pool.

Parameters:ipyparallel ({None, bool}) – if True, only tries to set up the ipyparallel pool. If False - only the multiprocessing. If None, first tries ipyparallel, and it does not succeed, then multiprocessing.
sleep(howlong=None)

Sleeps for the required number of seconds.

Parameters:howlong ({None, float}) – How long the pool should sleep for in seconds. If None (default), sleeps for “timestep”
timestep