uplink icon indicating copy to clipboard operation
uplink copied to clipboard

Rety mechanism leads to infinite loop for long requests

Open nikita-sheremet-java-developer opened this issue 8 months ago • 0 comments

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:

  1. request is made
  2. python code "waits" for 60 seconds
  3. response received after 2 minutes with 504 error code
  4. 2 minutes is 120 seconds that more than 60 seconds
  5. Are there any responses with 5xx during 60 seconds?
  6. No
  7. 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