executor
¶
-
class
invoke.executor.
Executor
(collection, config=None)¶ An execution strategy for Task objects.
Subclasses may override various extension points to change, add or remove behavior.
-
__init__
(collection, config=None)¶ Initialize executor with handles to a task collection & config.
Parameters: - collection – A
Collection
used to look up requested tasks (and their default config data, if any) by name during execution. - config – An optional
Config
holding configuration state Defaults to an emptyConfig
if not given.
- collection – A
-
__weakref__
¶ list of weak references to the object (if defined)
-
execute
(*tasks, **kwargs)¶ Execute one or more
tasks
in sequence.Parameters: tasks – An iterable of two-tuples whose first element is a task name and whose second element is a dict suitable for use as
**kwargs
. E.g.:[ ('task1', {}), ('task2', {'arg1': 'val1'}), ... ]
As a shorthand, a string instead of a two-tuple may be given, implying an empty kwargs dict.
The string specifies which task from the Executor’s
Collection
is to be executed. It may contain dotted syntax appropriate for calling namespaced tasks, e.g.subcollection.taskname
.Thus the above list-of-tuples is roughly equivalent to:
task1() task2(arg1='val1')
Returns: A dict mapping task objects to their return values. This dict may include pre- and post-tasks if any were executed. For example, in a collection with a
build
task depending on another task namedsetup
, executingbuild
will result in a dict with two keys, one forbuild
and one forsetup
.
-