Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Document backoff.runtime in readme #159

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.rst
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