Skip to content

SG-35165 Retry on URLError #342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 6, 2024

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.

@@ -449,7 +449,7 @@ def test_call_rpc(self):
self._mock_http(d, status=(504, "gateway timeout"))
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
24 checks passed
@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