Retry Utilities¶
Retry helper functions for libtmux test utilities. These utilities help manage testing operations that may require multiple attempts before succeeding.
Basic Retry Functionality¶
Retry helpers for libtmux and downstream libtmux libraries.
- libtmux.test.retry.retry_until(fun, seconds=8, *, interval=0.05, raises=True)[source]¶
Retry a function until a condition meets or the specified time passes.
- Return type:
bool
- Parameters:
fun (callable) – A function that will be called repeatedly until it returns
True
or the specified time passes.seconds (float) – Seconds to retry. Defaults to
8
, which is configurable viaRETRY_TIMEOUT_SECONDS
environment variables.interval (float) – Time in seconds to wait between calls. Defaults to
0.05
and is configurable viaRETRY_INTERVAL_SECONDS
environment variable.raises (bool) – Whether or not to raise an exception on timeout. Defaults to
True
.
Examples
>>> def fn(): ... p = session.active_window.active_pane ... return p.pane_current_path is not None
>>> retry_until(fn) True
In pytest:
>>> assert retry_until(fn, raises=False)