Runnable Strategy - Concurrent
- module multirunnable.concurrent
This subpackage responses of every features related with how to run in Concurrent.
Every running strategy or feature modules in MultiRunnable is an adapter which dispatches to call the Python package which truly implements parallelism features like multiprocessing or threading. Therefore, subpackage multirunable.concurrent uses threading (GeneralStrategy) or multiprocessing (PoolStrategy) to implement strategy module and feature module.
Thread Strategy
- class multirunnable.concurrent.strategy.ThreadStrategy
A generally runnable strategy object which controls runnable object. For RunningMode.Concurrent, it controls processes. This class is an adapter of object threading.Thread.
- initialization(queue_tasks, features, *args, **kwargs)
Initialing something before instantiating and running Threads.
- overload start_new_worker(target: (FunctionType, MethodType, PartialFunction), args, kwargs)
Instantiating and running Threads. Its logic is equal to instantiating threading.Thread and calling function run.
- overload start_new_worker(target: Iterable, args, kwargs)
Instantiating and running Threads.
- generate_worker(target, *args, **kwargs)
Instantiating Threads. Its logic is equal to instantiating threading.Thread.
- overload activate_workers(workers: Thread)
Running Threads. Its logic is equal to calling function run.
- overload activate_workers(workers: Iterable)
Running Threads.
- overload close(workers: Thread)
Close Threads. Its logic is equal to calling function join.
- overload close(workers: Iterable)
Close Threads.
- terminal()
No support this feature.
It is deprecated in version 0.16.0 and removed in version 0.17.0.
- kill()
No support this feature.
It is deprecated in version 0.16.0 and removed in version 0.17.0.
- get_result()
Get the result data of the running task in parallel. It returns a List type value and all the element in it is a MRResult type object.
Thread Pool Strategy
- class multirunnable.concurrent.strategy.ThreadPoolStrategy
A pooled strategy class which controls a pool of runnable objects. For RunningMode.Concurrent, it controls pool of processes. This class is an adapter of object multiprocessing.pool.ThreadPool. And the feature of mostly APIs of this class is the same as multiprocessing.pool.ThreadPool. So below only recording some functions which is different or new.
- initialization(queue_tasks, features, *args, **kwargs)
The initialization before run in concurrent. It also initials features or queues here.
- close()
It call methods close and join in object multiprocessing.pool.ThreadPool.
- get_result()
Get the result data of the running task in parallel. It returns a List type value and all the element in it is a PoolResult type object.