Execution¶
LazyExecutionChain(fn)
¶
Bases: LazyExecutionNode[P, R]
Root execution chain entry point.
Represents the starting node of a lazy execution chain. The chain remains inert until explicitly initialized and awaited.
init(*args, **kwargs)
¶
Initializes the execution chain.
Binds arguments to the root callable and prepares the chain for execution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
args
|
Positional arguments passed to the root callable. |
()
|
**kwargs
|
kwargs
|
Keyword arguments passed to the root callable. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
The initialized execution chain. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the chain has already been attached to a parent. |
LazyExecutionNode(fn, *, parent=None)
¶
Bases: Generic[P, R]
Lazy asynchronous execution node.
Represents a single step in an execution chain. Each node wraps an asynchronous callable and may reference a parent node whose result is used as input.
Execution is deferred until the node is awaited. When awaited, the entire chain is resolved sequentially from the root to the current node.
then(nxt, **kwargs)
¶
Appends a new execution node to the chain.
The provided callable is wrapped and executed after the current node resolves. Keyword arguments are bound eagerly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nxt
|
Callable[..., Coroutine[None, None, K]]
|
Asynchronous callable executed after this node. |
required |
**kwargs
|
Any
|
Keyword arguments bound to the callable. |
{}
|
Returns:
| Type | Description |
|---|---|
LazyExecutionNode[[R], K]
|
A new lazy execution node attached to the current one. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the root node has not been initialized. |