Concurrent For Loop
Executes a loop body concurrently for a range of numbers.
This node iterates from First Index to Last Index (inclusive) and executes the Body branch for each number in the range.
The key feature is its ability to run iterations in parallel, which can significantly speed up workflows that involve many independent, repeated operations.
Concurrency#
The level of parallelism is controlled by Worker Count:
- Worker Count > 0: A fixed number of workers will process the loop iterations concurrently. For example, with 100 iterations and 4 workers, each worker will handle roughly 25 iterations.
- Worker Count = 0: The node will attempt to run all iterations simultaneously, creating a separate worker for each one. This provides maximum parallelism but can be resource-intensive. Use with caution for large ranges.
- Global Concurrency Disabled: If concurrency is disabled in the application settings, this node will behave like a standard, sequential for-loop, processing one iteration at a time, regardless of the Worker Count setting.
Execution Flow#
- The loop starts when the
execinput is triggered. - Iterations are distributed among the available workers.
- The
Completedoutput is executed only after all iterations have finished successfully. - If an error occurs in any iteration, the node will cancel all other running and pending iterations. The error will be propagated, and the
Completedbranch will not be executed.
Inputs#
| Port | Description |
|---|---|
| Starts the loop execution. | |
| The starting number for the loop (inclusive). | |
| The ending number for the loop (inclusive). | |
| Number of parallel workers. Set to 0 for maximum concurrency. Runs sequentially if global concurrency is off. |
Outputs#
| Port | Description |
|---|---|
| Executes for each iteration of the loop. | |
| The current iteration number. | |
| Executes once all iterations have completed without error. |
ID: core/concurrent-for-loop@v1