uplink
uplink copied to clipboard
Rety mechanism leads to infinite loop for long requests
To Reproduce Consider a code:
from uplink import retry, Consumer, get
class MyApi(Consumer):
@retry(
when=retry.when.status_5xx(),
stop=retry.stop.after_delay(60),
backoff=retry.backoff.fixed(5)
)
@get("mypath")
def make_request(self):
""""""
Then make a request:
MyApi(base_url="https://my-api.com").make_request()
Expected behavior Retry stopped after 60 seconds
Actual behavior
When it takes about 2+ minute for response with 504 http code - retry will lead to infinite loop.
I understand it this way:
- request is made
- python code "waits" for 60 seconds
- response received after 2 minutes with 504 error code
- 2 minutes is 120 seconds that more than 60 seconds
- Are there any responses with
5xxduring 60 seconds? - No
- lets retry request
And this cycle continues forever.
The problem here that there is no logic for counting responses in total during retries. And there are
uplink version is 0.9.7