jztools.parallelization.multiprocessing.outsourced_iterable#
Classes
|
Takes an iterable and runs it in another process, transferring data between processes using a queue. |
- class jztools.parallelization.multiprocessing.outsourced_iterable.ProcessOutsourcedIterable(source: Iterable, initializer: Callable[[Iterable], None] | None = None, finalizer: Callable[[Iterable], None] | None = None, filter: Callable[[Any], bool] | None = None, mapper: Callable[[Any], Any] | None = None, post_filter: Callable[[Any], bool] | None = None, queue_size: int = 2, name=None)#
Bases:
OutsourcedIterableTakes an iterable and runs it in another process, transferring data between processes using a queue.
- Parameters:
source – The iterable object to run in the remotely process. Depending on the multiprocessing process start method (see this discussion), the object might need to support pickling.
initializer – Called at the start of the worker process. See Process initializer / finalizer.
finalizer – Called in the worker process at the end of normal or abnormal (because of an exception) execution. See Process initializer / finalizer.
Process initializer / finalizer
Both
initializerandfinalizerrun in the remote worker process and take the process’s copy ofsourceas their only input parameter. Both callables must be module-level functions (including static and class methods of non-dynamically defined classes).- Parameters:
source – The iterable object to outsource.
initializer – Called at the start of the worker process, with
sourceas an argument.finalizer – Called in the worker process at the end of normal or abnormal (because of an exception) execution, with
sourceas an argument.filter – Items will be placed in the queue only if this returns
Truefor that item.mapper – Applied to each item before placing it in the queue.
post_filter – Items will be placed in the queue only if this returns
Truefor the mapped item.queue_size – The size of the queue to pre-compute.
name – The name given to the spawned work unit (e.g., thread or process).
- Queue(maxsize=0)#
Returns a queue object
- Event()#
Returns an event object
- Spawner#
alias of
Process