jpt.base.utils.multicore

Classes

InheritLocalDataThread

Custom subclass of threading.Thread that allows to inherit

DummyPool

Pool

Class which supports an async version of applying functions to arguments.

Functions

worker(inqueue, outqueue[, initializer, initargs, ...])

Module Contents

class jpt.base.utils.multicore.InheritLocalDataThread(target: Callable, args: Tuple[Any, Ellipsis], local: threading.local | None)

Bases: 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.

_local
_local_data
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.

jpt.base.utils.multicore.worker(inqueue, outqueue, initializer=None, initargs=(), maxtasks=None, wrap_exception=False, terminator=None, termargs=())
class jpt.base.utils.multicore.DummyPool(processes: int | None = None, initializer: Callable | None = None, initargs: Tuple = (), terminator: Callable | None = None, termargs: Tuple = (), maxtasksperchild: int | None = None, local: threading.local | None = None)
initializer = None
initargs = ()
terminator = None
termargs = ()
_queue
_execting = False
imap_unordered(func, iterable, chunksize=1)
map(func, iterable, chunksize=None)
starmap(func, iterable, chunksize=None)
apply_async(func, args, callback, error_callback)
terminate()
join()
close()
__enter__()
__exit__(exc_type, exc_val, exc_tb) bool
class jpt.base.utils.multicore.Pool(processes: int | None = None, initializer: Callable | None = None, initargs: Tuple = (), terminator: Callable | None = None, termargs: Tuple = (), maxtasksperchild: int | None = None, local: threading.local | None = None)

Bases: multiprocessing.pool.Pool

Class which supports an async version of applying functions to arguments.

_pool = []
_state = 'INIT'
_ctx = None
_taskqueue
_change_notifier
_cache
_maxtasksperchild = None
_initializer = None
_initargs = ()
_terminator = None
_termargs = ()
_processes = None
_worker_handler
_task_handler
_result_handler
_terminate
_repopulate_pool()
static _repopulate_pool_static(ctx, Process, processes, pool, inqueue, outqueue, initializer, initargs, maxtasksperchild, wrap_exception, terminator, termargs)

Bring the number of pool processes up to the specified number, for use after reaping workers which have exited.