Skip to content

Conversation

@alexgromero
Copy link

Description of changes:
Adds support for a new retry mode: standard. This behavior is now consistent with other AWS SDKs implementing standard mode. This mode also adds support for retry quotas which control how many unsuccessful retries a client can make.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@alexgromero alexgromero requested a review from a team as a code owner August 22, 2025 18:28
Copy link
Contributor

@jonathan343 jonathan343 left a comment

Choose a reason for hiding this comment

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

Thanks Alessandra!
Looks great so far. I have a few suggestions below.

async def refresh_retry_token_for_retry(
self,
*,
token_to_renew: StandardRetryToken,
Copy link
Contributor

@jonathan343 jonathan343 Aug 28, 2025

Choose a reason for hiding this comment

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

This is going to result in the following typechecker errors:

/.../smithy-python/packages/smithy-core/src/smithy_core/retries.py
  /.../smithy-python/packages/smithy-core/src/smithy_core/retries.py:288:15 - error: Method "refresh_retry_token_for_retry" overrides class "RetryStrategy" in an incompatible manner
    Keyword parameter "token_to_renew" type mismatch: base parameter is type "RetryToken", override parameter is type "StandardRetryToken"
      "RetryToken" is not assignable to "StandardRetryToken" (reportIncompatibleMethodOverride)
  /.../smithy-python/packages/smithy-core/src/smithy_core/retries.py:331:15 - error: Method "record_success" overrides class "RetryStrategy" in an incompatible manner
    Keyword parameter "token" type mismatch: base parameter is type "RetryToken", override parameter is type "StandardRetryToken"
      "RetryToken" is not assignable to "StandardRetryToken" (reportIncompatibleMethodOverride)

I think we need to be using retries_interface.RetryToken here instead of StandardRetryToken.

Suggested change
token_to_renew: StandardRetryToken,
token_to_renew: retries_interface.RetryToken,

Making this change alone will result in even more typing errors because StandardRetryToken has extra attributes. I think we have the following options:

  • Use typing.cast to tell the typechecker we're using StandardRetryToken
  • Add a runtime check to validate StandardRetryToken is being used

Copy link
Author

Choose a reason for hiding this comment

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

Good catch. Thanks for the suggestions! I went with the second option and the type checks are passing now.

:param max_attempts: Upper limit on total number of attempts made, including
initial attempt and retries.
"""
self.backoff_strategy = ExponentialRetryBackoffStrategy(
Copy link
Contributor

Choose a reason for hiding this comment

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

I know the max_backoff is 20 seconds and it would be a bit redundant to specify that here, but I feel like that is the safer thing to do. If for some reason we decided that a different default is better for non-AWS clients, I don't want us to accidentally change the value used here.

Copy link
Author

Choose a reason for hiding this comment

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

That's a good point. I added it in the new revision

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.

3 participants