Skip to content

Conversation

carlos-villavicencio-adsk
Copy link
Contributor

  • Add retry only when encountering an URLError
  • Adopt the existing strategy
  • Add tests

# response headers are in str(resp.info()).splitlines()
except urllib.error.URLError as e:
LOG.debug("Got a %s response. Waiting and retrying..." % e)
time.sleep(float(attempt) * self.BACKOFF)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with this loop is that, in the worst case scenario, where every attempt failed, you end up sleeping before leaving the loop.

self.assertRaises(api.ProtocolError, self.sg._call_rpc, "list", a)
self.assertEqual(
4,
3,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I standardize the number of retries to be reused on the library.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use self.sgMAX_ATTEMPTS instead or does it make sense to keep these 3 everywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's feasible.

Copy link
Contributor

@julien-lang julien-lang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@carlos-villavicencio-adsk carlos-villavicencio-adsk merged commit b61ed09 into master Jun 6, 2024
@carlos-villavicencio-adsk carlos-villavicencio-adsk deleted the ticket/SG-35165_retry_on_urlerror branch June 6, 2024 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants