jpt.base.utils.multicore ======================== .. py:module:: jpt.base.utils.multicore Classes ------- .. autoapisummary:: jpt.base.utils.multicore.InheritLocalDataThread jpt.base.utils.multicore.DummyPool jpt.base.utils.multicore.Pool Functions --------- .. autoapisummary:: jpt.base.utils.multicore.worker Module Contents --------------- .. py:class:: InheritLocalDataThread(target: Callable, args: Tuple[Any, Ellipsis], local: Optional[threading.local]) Bases: :py:obj:`threading.Thread` Custom subclass of ``threading.Thread`` that allows to inherit ``threading.local`` data from its parent thread. This constructor should always be called with keyword arguments. Arguments are: *group* should be None; reserved for future extension when a ThreadGroup class is implemented. *target* is the callable object to be invoked by the run() method. Defaults to None, meaning nothing is called. *name* is the thread name. By default, a unique name is constructed of the form "Thread-N" where N is a small decimal number. *args* is a list or tuple of arguments for the target invocation. Defaults to (). *kwargs* is a dictionary of keyword arguments for the target invocation. Defaults to {}. If a subclass overrides the constructor, it must make sure to invoke the base class constructor (Thread.__init__()) before doing anything else to the thread. .. py:attribute:: _local .. py:attribute:: _local_data .. py:method:: run() Method representing the thread's activity. You may override this method in a subclass. The standard run() method invokes the callable object passed to the object's constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively. .. py:function:: worker(inqueue, outqueue, initializer=None, initargs=(), maxtasks=None, wrap_exception=False, terminator=None, termargs=()) .. py:class:: DummyPool(processes: Optional[int] = None, initializer: Optional[Callable] = None, initargs: Tuple = (), terminator: Optional[Callable] = None, termargs: Tuple = (), maxtasksperchild: Optional[int] = None, local: Optional[threading.local] = None) .. py:attribute:: initializer :value: None .. py:attribute:: initargs :value: () .. py:attribute:: terminator :value: None .. py:attribute:: termargs :value: () .. py:attribute:: _queue .. py:attribute:: _execting :value: False .. py:method:: imap_unordered(func, iterable, chunksize=1) .. py:method:: map(func, iterable, chunksize=None) .. py:method:: starmap(func, iterable, chunksize=None) .. py:method:: apply_async(func, args, callback, error_callback) .. py:method:: terminate() .. py:method:: join() .. py:method:: close() .. py:method:: __enter__() .. py:method:: __exit__(exc_type, exc_val, exc_tb) -> bool .. py:class:: Pool(processes: Optional[int] = None, initializer: Optional[Callable] = None, initargs: Tuple = (), terminator: Optional[Callable] = None, termargs: Tuple = (), maxtasksperchild: Optional[int] = None, local: Optional[threading.local] = None) Bases: :py:obj:`multiprocessing.pool.Pool` Class which supports an async version of applying functions to arguments. .. py:attribute:: _pool :value: [] .. py:attribute:: _state :value: 'INIT' .. py:attribute:: _ctx :value: None .. py:attribute:: _taskqueue .. py:attribute:: _change_notifier .. py:attribute:: _cache .. py:attribute:: _maxtasksperchild :value: None .. py:attribute:: _initializer :value: None .. py:attribute:: _initargs :value: () .. py:attribute:: _terminator :value: None .. py:attribute:: _termargs :value: () .. py:attribute:: _processes :value: None .. py:attribute:: _worker_handler .. py:attribute:: _task_handler .. py:attribute:: _result_handler .. py:attribute:: _terminate .. py:method:: _repopulate_pool() .. py:method:: _repopulate_pool_static(ctx, Process, processes, pool, inqueue, outqueue, initializer, initargs, maxtasksperchild, wrap_exception, terminator, termargs) :staticmethod: Bring the number of pool processes up to the specified number, for use after reaping workers which have exited.