Skip to content

Rety mechanism leads to infinite loop for long requests #330

@nikita-sheremet-java-developer

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions