prkumar / uplink

A Declarative HTTP Client for Python
https://uplink.readthedocs.io/
MIT License
1.07k stars 61 forks source link

@retry should respect 429 `Retry-After` headers #238

Open prkumar opened 2 years ago

prkumar commented 2 years ago

Discussed in https://github.com/prkumar/uplink/discussions/235

Originally posted by **mivade** December 20, 2021 [RFC 6585](https://datatracker.ietf.org/doc/html/rfc6585) describes the 429 status code to indicate hitting rate limits. This type of response may include a `Retry-After` header indicating the time in seconds to wait before trying again. Naively I would expect to be able to define my own backoff function to parse this header and yield that value to indicate how long to wait, but it looks like backoff functions have no knowledge of the response itself. Is there a way to get this functionality?
prkumar commented 2 years ago

Some additional context: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After

prkumar commented 2 years ago

The new RetryBackoff class is available now in v0.9.6!