Skip to content

SG-38213 Prevent unexpected retries on error #379

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

carlos-villavicencio-adsk
Copy link
Contributor

@carlos-villavicencio-adsk carlos-villavicencio-adsk commented May 5, 2025

We want to control when python-api does a retry on error.

  • SSLEOFError
  • SSLHandshakeError

On _make_call function.

We don't want to retry on a general exceptions (e.g. Timeout or remote disconnection) because we might send a resource modification request (create, batch create, etc) and we can end up duplicating things. It seems this concern was already identified before.

@carlos-villavicencio-adsk carlos-villavicencio-adsk requested a review from a team May 5, 2025 21:00
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.

Looks good but I am worried we are going to create new regressions with removing that retry.

Did you identify when and why this retry on generic exceptions was introduced?

@carlos-villavicencio-adsk
Copy link
Contributor Author

Looks good but I am worried we are going to create new regressions with removing that retry.

Did you identify when and why this retry on generic exceptions was introduced?

It seems this concern was already identified before.

If any regression happened, that can help us identify better use cases (and we can always let the customers use the previous versions).

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.

Just 2 minor points, then I'll be happy :)

Co-authored-by: Julien Langlois <[email protected]>
julien-lang
julien-lang previously approved these changes May 7, 2025
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!

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refines retry behavior in the Python API by logging exception reasons and updating tests to expect no automatic retries on general errors.

  • Updated tests to assert a single call and removed sleep interval checks.
  • Enhanced _make_call to log exception messages (e) on failures.
  • Bumped version in HISTORY.rst with a note about changing retry policy.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
tests/test_client.py Updated assertion to expect a single HTTP call
tests/test_api.py Removed multi-retry assertions and adjusted log check
shotgun_api3/shotgun.py Changed exception handler to log the error reason
HISTORY.rst Added v3.8.5 entry explaining new retry policy
Comments suppressed due to low confidence (2)

tests/test_client.py:334

  • [nitpick] The assertion message still says "Call is repeated" but the test now expects only one call (no repeat). Consider updating this message to accurately reflect that no retries should occur.
"Call is repeated"

tests/test_api.py:2227

  • The test checks the log message but doesn’t verify that the request was only called once. Add an assertion on mock_request.call_count to ensure general exceptions do not trigger retries.
"Request failed.  Reason: not working",

Comment on lines 3942 to +3943
self._close_connection()
if attempt == max_rpc_attempts:
LOG.debug("Request failed. Giving up after %d attempts." % attempt)
raise
LOG.debug(f"Request failed. Reason: {e}", exc_info=True)
Copy link
Preview

Copilot AI Jun 13, 2025

Choose a reason for hiding this comment

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

Catching all Exception means non-SSL errors will still trigger retry logic. Limit retry handling to specific SSL errors (e.g. SSLEOFError, SSLHandshakeError) and re-raise other exceptions immediately.

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

False, we handle this on the first two except blocks.

julien-lang
julien-lang previously approved these changes Jun 13, 2025
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!

Just one minor comment

Co-authored-by: Julien Langlois <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants