teff.node.parallel¶
teff.node.parallel
¶
Parallel node — runs independent branches concurrently.
Classes:
| Name | Description |
|---|---|
Parallel |
Execute several branch chains concurrently and merge their results. |
Parallel
¶
Bases: Node
Execute several branch chains concurrently and merge their results.
Each branch is a list of nodes run sequentially on an isolated
copy of the state. Branches run concurrently via gather_or_cancel;
only the updates each node returns are merged back (per-key
reducers apply, so append branches accumulate instead of
overwriting one another).
Because branches read from independent copies, direct in-place mutation of the passed state is not propagated. Nodes inside branches should return their updates — the constitution's contract: receive state → return state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
branches
|
list[Node | list[Node]]
|
Sequence of branches, each a single :class: |
required |
Usage::
node = Parallel([[upper_node, count_node], [tag_node]])
Source code in teff/node/parallel.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |