taps.executor.utils¶
FutureDependencyExecutor
¶
FutureDependencyExecutor(executor: Executor)
Bases: Executor
Executor wrapper that adds DAG-like features.
An Executor
implementation that wraps
another executor with logic for delaying task submission until all
Future
instances which are args or kwargs
of a task have completed. In other words, child tasks will not be
scheduled until the results of the child's parent tasks are available.
Parameters:
-
executor
(Executor
) –Executor to wrap.
Source code in taps/executor/utils.py
submit
¶
Schedule the callable to be executed.
Parameters:
-
function
(Callable[P, T]
) –Callable to execute.
-
args
(args
, default:()
) –Positional arguments.
-
kwargs
(kwargs
, default:{}
) –Keyword arguments.
Returns:
Source code in taps/executor/utils.py
map
¶
map(
function: Callable[P, T],
*iterables: Iterable[args],
timeout: float | None = None,
chunksize: int = 1
) -> Iterator[T]
Map a function onto iterables of arguments.
Parameters:
-
function
(Callable[P, T]
) –A callable that will take as many arguments as there are passed iterables.
-
iterables
(Iterable[args]
, default:()
) –Variable number of iterables.
-
timeout
(float | None
, default:None
) –The maximum number of seconds to wait. If None, then there is no limit on the wait time.
-
chunksize
(int
, default:1
) –If greater than one, the iterables will be chopped into chunks of size chunksize and submitted to the executor. If set to one, the items in the list will be sent one at a time.
Returns:
-
Iterator[T]
–An iterator equivalent to:
map(func, *iterables)
but the calls may be evaluated out-of-order.
Raises:
-
ValueError
–if chunksize is less than one.
Source code in taps/executor/utils.py
shutdown
¶
Shutdown the executor.
Parameters:
-
wait
(bool
, default:True
) –Wait on all pending futures to complete.
-
cancel_futures
(bool
, default:False
) –Cancel all pending futures that the executor has not started running. Only used in Python 3.9 and later.