While loops
While loops execute a sequence of code indefinitely until the user cancels or a step set to Early stop stops.
How to stop a while loop
The loop will continue to run until canceled, there are 3 ways to stop a while loop:
- Cancel manually
- Early stop/Break for loop
- Early stop for step
Cancel manually
You can cancel flow manually from the flow page, it can be accessed when the flow is triggered manually or from the Runs page.
Early stop / Break
The Early stop/Break feature allows you to define a predicate expression that determines whether the flow - or here, loop - should stop early at the end or before a step.
Early stop for step
For each step of the flow, an early stop can be defined. The result of the step will be compared to a previously defined predicate expression, and if the condition is met, the flow will stop after that step.
Skip failure
If set to true, the loop will continue to the next item even if the current item failed.
Squash
If set to true, all iterations will be run on the same worker.
In addition, for supported languages (TypeScript and Python), a single runner per step will be used for the entire loop, eliminating cold starts between iterations.
We use the same logic as for Dedicated workers, but the worker is only "dedicated" to the flow steps for the duration of the loop.
Test an iteration
You can get a test of the current iteration by clicking on the Test an iteration button.
Advanced settings
Early stop / Break
See above.
Suspend/Approval/Prompt
Flows can be suspended until resumed or canceled event(s) are received. This feature is most useful for implementing approval steps but can be used for other purposes as well.
Sleep
Executions within a flow can be suspended for a given time.
Mock
Step mocking / Pin result allows faster iteration while building flows. When a step is mocked, it will immediately return the mocked value without performing any computation.
Lifetime
The logs, arguments and results of this flow step will be completely deleted from Windmill once the flow is complete.