# Repeat Example
URL: /examples/repeat
The upstream repeat.py example — retry a phase on a plug exception with PhaseResult.REPEAT, and cap retries on a bad result with PhaseOptions(repeat_limit=5).
Two phases that retry themselves: one after an exception, one after an unwanted result, with a cap. Based on `examples/repeat.py`.
Run the phase again, ignoring this attempt's measurements. Each attempt is recorded as its own `PhaseRecord` with outcome `SKIP`, and the final one carries the result. Results →
When `REPEAT` is returned more than `repeat_limit` times the framework treats it as `STOP`, hence the `FAIL` above. Without the option the default limit applies (`DEFAULT_REPEAT_LIMIT`, 3 in 1.6.1); set `repeat_limit=None` for unlimited. Options →
`phase_repeat(test_plug)` takes only the plug. The `test` parameter is optional; OpenHTF inspects the signature.
The plug is instantiated once per test, so `self.count` survives repeats — which is what lets `FailTwicePlug` succeed on the third try. Plugs →
`repeat_on_measurement_fail=True` repeats automatically when a measurement fails validation — no `REPEAT` needed in the phase body.
`repeat_on_timeout=True` repeats after `timeout_s` expires.
`force_repeat=True` repeats `repeat_limit` times regardless of result (soak-style loops).