dcnum.common

Attributes

h5py

Lazily loaded h5py module

Classes

LazyLoader

Lazily load a module

Functions

cpu_count(→ int)

Get the number of processes

join_worker(worker[, timeout, retries, logger, name])

Patiently join a worker (Thread or Process)

start_workers_threaded(worker_list, logger, name)

setup_h5py(h5py)

Hook for LazyLoader that imports hdf5plugin

Module Contents

class dcnum.common.LazyLoader(modname: str, sibling: str = None, action: Callable = None)[source]

Lazily load a module

Parameters:
  • modname (str) – The name of the module (e.g. "scipy.ndimage")

  • sibling (str) –

    The __name__ of a sibling of the module. This is useful for performing relative imports. Consider this module structure:

    • module - submod_1 - submod_2

    If submod_1 would like to lazily import submod_2:

    submod_2 = LazyLoader("submod_2", sibling==__name__)
    

  • action (Callable) – Method that should be called after the actual import. Must accept the module as an argument. This is useful if any setup steps need to be made after import (e.g. for ensuring reproducibility).

_modname
_mod = None
_action = None
__getattr__(attr)[source]

If the module is accessed, load it and return what was asked for

dcnum.common.cpu_count() int[source]

Get the number of processes

Try to get the number of CPUs the current process can use first. Fallback to mp.cpu_count()

dcnum.common.join_worker(worker, timeout=30, retries=10, logger=None, name=None)[source]

Patiently join a worker (Thread or Process)

dcnum.common.start_workers_threaded(worker_list, logger, name)[source]
dcnum.common.setup_h5py(h5py)[source]

Hook for LazyLoader that imports hdf5plugin

dcnum.common.h5py

Lazily loaded h5py module