Waiter is a lightweight Python library providing utilities for delayed iteration, polling, and retrying operations. It's particularly useful for waiting for external resources, services, or conditions to become ready. The current version is 1.5.1, and it maintains an active release cadence with regular updates.
pip install waiterVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates using `waiter.until_successful` to poll a function that initially fails but eventually succeeds. It illustrates how to define a retriable operation and handle potential `TimeoutError`.
Update your code to use `pause` instead of `sleep_seconds`. For example, `waiter.until(my_func, pause=1)`.
Ensure you provide an iterable object to `waiter.wait`. If you intend to poll a function, use `waiter.until` or `waiter.until_successful` instead. Example: `for _ in waiter.wait(range(10), pause=0.5): ...`
If your condition for retrying is a falsy return value, use `waiter.until`. If it's an exception, use `waiter.until_successful`. For example, `until(check_condition, timeout=10)` will retry if `check_condition()` returns `False` or `None`.
Always wrap your `waiter` calls in a `try...except TimeoutError` block to gracefully handle scenarios where the condition isn't met in time.
Provide an iterable object to `waiter.wait`. If you intended to poll a function for success, use `waiter.until` or `waiter.until_successful`. Correct example: `for _ in waiter.wait(range(5), pause=1): print('Waiting...')`Ensure you pass the function reference (the function name without parentheses) to `until` or `until_successful`. Correct example: `until_successful(my_function, timeout=5)` instead of `until_successful(my_function(), timeout=5)`.
Increase the `timeout` parameter if the operation genuinely takes longer, or decrease `pause` if more frequent checks are needed. Review the logic of your callable to ensure it eventually succeeds. Always catch `TimeoutError` to handle the failure gracefully.
No dependency data recorded yet.