Skip to content

SG-35165 Retry on URLError#342

Merged
carlos-villavicencio-adsk merged 4 commits into
masterfrom
ticket/SG-35165_retry_on_urlerror
Jun 6, 2024
Merged

SG-35165 Retry on URLError#342
carlos-villavicencio-adsk merged 4 commits into
masterfrom
ticket/SG-35165_retry_on_urlerror

Conversation

@carlos-villavicencio-adsk
Copy link
Copy Markdown
Contributor

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

Comment thread shotgun_api3/shotgun.py
# 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
Copy Markdown
Member

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.

Comment thread tests/test_client.py Outdated
self.assertRaises(api.ProtocolError, self.sg._call_rpc, "list", a)
self.assertEqual(
4,
3,
Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
Member

@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