Skip to content
This repository was archived by the owner on Aug 8, 2025. It is now read-only.

Commit 8fdd111

Browse files
docs: Document backoff.runtime in readme
1 parent 92e7b6e commit 8fdd111

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,25 @@ gets a non-falsey result could be defined like like this:
172172
173173
The jitter is disabled in order to keep the polling frequency fixed.
174174

175+
@backoff.runtime
176+
----------------
177+
178+
You can also use the ``backoff.runtime`` generator to make use of the
179+
return value or thrown exception of the decorated method.
180+
181+
For example, to use the value in the ``Retry-After`` header of the response:
182+
183+
.. code-block:: python
184+
185+
@backoff.on_predicate(
186+
backoff.runtime,
187+
predicate=lambda r: r.status_code == 429,
188+
value=lambda r: int(r.headers.get("Retry-After")),
189+
jitter=None,
190+
)
191+
def get_url():
192+
return requests.get(url)
193+
175194
Jitter
176195
------
177196

0 commit comments

Comments
 (0)