dcnum.common ============ .. py:module:: dcnum.common Attributes ---------- .. autoapisummary:: dcnum.common.h5py Classes ------- .. autoapisummary:: dcnum.common.LazyLoader Functions --------- .. autoapisummary:: dcnum.common.cpu_count dcnum.common.join_worker dcnum.common.start_workers_threaded dcnum.common.setup_h5py Module Contents --------------- .. py:class:: LazyLoader(modname: str, sibling: str = None, action: Callable = None) Lazily load a module :param modname: The name of the module (e.g. ``"scipy.ndimage"``) :type modname: str :param sibling: 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__) :type sibling: str :param action: 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). :type action: Callable .. py:attribute:: _modname .. py:attribute:: _mod :value: None .. py:attribute:: _action :value: None .. py:method:: __getattr__(attr) If the module is accessed, load it and return what was asked for .. py:function:: cpu_count() -> int Get the number of processes Try to get the number of CPUs the current process can use first. Fallback to `mp.cpu_count()` .. py:function:: join_worker(worker, timeout=30, retries=10, logger=None, name=None) Patiently join a worker (Thread or Process) .. py:function:: start_workers_threaded(worker_list, logger, name) .. py:function:: setup_h5py(h5py) Hook for LazyLoader that imports hdf5plugin .. py:data:: h5py Lazily loaded h5py module