jztools.parallelization.outsourced_callable_base#
Classes
|
Handy when a callable needs to be passed but it should execute in a different e.g., thread. |
- class jztools.parallelization.outsourced_callable_base.OutsourcedCallable(executor: Executor, callable: Callable)#
Bases:
objectHandy when a callable needs to be passed but it should execute in a different e.g., thread.
Example:
from jztools.parallelization.threading import ThreadOutsourcedCallable from concurrent.futures import ThreadPoolExecutor def my_callable(value): print("Output of `my_callable`:", value) with ThreadPoolExecutor() as executor: wrapped_callable = ThreadOutsourcedCallable(executor, my_callable) wrapped_callable(5) wrapped_callable.wait()
Output of `my_callable`: 5
- __call__(*args, **kwargs)#
Call self as a function.