Skip to content

Commit

Permalink
Merge pull request #159 from edgarrmondragon/docs/backoff-runtime-readme
Browse files Browse the repository at this point in the history
docs: Document `backoff.runtime` in readme
  • Loading branch information
bgreen-litl authored Oct 5, 2022
2 parents d322dc4 + 8fdd111 commit 9a20a7f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,25 @@ gets a non-falsey result could be defined like like this:
The jitter is disabled in order to keep the polling frequency fixed.

@backoff.runtime
----------------

You can also use the ``backoff.runtime`` generator to make use of the
return value or thrown exception of the decorated method.

For example, to use the value in the ``Retry-After`` header of the response:

.. code-block:: python
@backoff.on_predicate(
backoff.runtime,
predicate=lambda r: r.status_code == 429,
value=lambda r: int(r.headers.get("Retry-After")),
jitter=None,
)
def get_url():
return requests.get(url)
Jitter
------

Expand Down

0 comments on commit 9a20a7f

Please sign in to comment.