pimlico.core.modules.map.threaded module¶
Just like multiprocessing, but using threading instead. If you’re not sure which you should use, it’s probably multiprocessing.
-
class
pimlico.core.modules.map.threaded.
ThreadingMapModuleExecutor
(module_instance_info, **kwargs)[source]¶ Bases:
pimlico.core.modules.map.DocumentMapModuleExecutor
-
POOL_TYPE
= None¶
-
-
class
pimlico.core.modules.map.threaded.
ThreadingMapPool
(executor, processes)[source]¶ Bases:
pimlico.core.modules.map.DocumentProcessorPool
-
THREAD_TYPE
= None¶
-
-
class
pimlico.core.modules.map.threaded.
ThreadingMapThread
(input_queue, output_queue, exception_queue, executor)[source]¶ Bases:
threading.Thread
,pimlico.core.modules.map.DocumentMapProcessMixin
-
pimlico.core.modules.map.threaded.
threading_executor_factory
(process_document_fn, preprocess_fn=None, postprocess_fn=None, worker_set_up_fn=None, worker_tear_down_fn=None)[source]¶ Factory function for creating an executor that uses the threading-based implementations of document-map pools and worker processes.
process_document_fn should be a function that takes the following arguments:
- the worker process instance (allowing access to things set during setup)
- archive name
- document name
- the rest of the args are the document itself, from each of the input corpora
If proprocess_fn is given, it is called from the main thread once before execution begins, with the executor as an argument.
If postprocess_fn is given, it is called from the main thread at the end of execution, including on the way out after an error, with the executor as an argument and a kwarg error which is True if execution failed.
If worker_set_up_fn is given, it is called within each worker before execution begins, with the worker thread instance as an argument. Likewise, worker_tear_down_fn is called from within the worker thread before it exits.
Alternatively, you can supply a worker type, a subclass of :class:.ThreadingMapThread, as the first argument. If you do this, worker_set_up_fn and worker_tear_down_fn will be ignored.