From 781d6fefe887d14c60f5a2fbcefb47b25abe5e2c Mon Sep 17 00:00:00 2001 From: jonathan343 Date: Sun, 21 Jun 2026 01:21:28 -0400 Subject: [PATCH] Address review follow-ups from async retry refactor. --- designs/retries.md | 8 ++++---- ...hy-core-breaking-e1d59c61d8344b88832fc481dbc16531.json | 4 ++-- packages/smithy-core/src/smithy_core/aio/retries.py | 5 ++--- .../smithy-core/src/smithy_core/interfaces/retries.py | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/designs/retries.md b/designs/retries.md index 9f452d413..5d681f71d 100644 --- a/designs/retries.md +++ b/designs/retries.md @@ -146,14 +146,14 @@ example: try: retry_token = await retry_strategy.acquire_initial_retry_token() except RetryError: - transport_response = transport_client.send(serialized_request) - return self._deserialize(transport_response) + transport_response = await transport_client.send(serialized_request) + return await self._deserialize(transport_response) while True: await asyncio.sleep(retry_token.retry_delay) try: - transport_response = transport_client.send(serialized_request) - response = self._deserialize(transport_response) + transport_response = await transport_client.send(serialized_request) + response = await self._deserialize(transport_response) except Exception as e: response = e diff --git a/packages/smithy-core/.changes/next-release/smithy-core-breaking-e1d59c61d8344b88832fc481dbc16531.json b/packages/smithy-core/.changes/next-release/smithy-core-breaking-e1d59c61d8344b88832fc481dbc16531.json index 484d18598..3e3eaa646 100644 --- a/packages/smithy-core/.changes/next-release/smithy-core-breaking-e1d59c61d8344b88832fc481dbc16531.json +++ b/packages/smithy-core/.changes/next-release/smithy-core-breaking-e1d59c61d8344b88832fc481dbc16531.json @@ -1,4 +1,4 @@ { "type": "breaking", - "description": "Refactored retry strategies to be async, allowing them to wait internally or use async synchronization primitives if necessary." -} \ No newline at end of file + "description": "Refactored retry strategies to be async, allowing them to wait internally or use async synchronization primitives if necessary. The `RetryStrategy` protocol moved from `smithy_core.interfaces.retries` to `smithy_core.aio.interfaces.retries`, and `SimpleRetryStrategy`, `StandardRetryStrategy`, and `RetryStrategyResolver` moved from `smithy_core.retries` to `smithy_core.aio.retries`." +} diff --git a/packages/smithy-core/src/smithy_core/aio/retries.py b/packages/smithy-core/src/smithy_core/aio/retries.py index bf9d255ed..e3fa6340e 100644 --- a/packages/smithy-core/src/smithy_core/aio/retries.py +++ b/packages/smithy-core/src/smithy_core/aio/retries.py @@ -1,7 +1,7 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0 from functools import lru_cache -from typing import Any, Literal +from typing import Any from ..exceptions import RetryError from ..interfaces import retries as retries_interface @@ -9,14 +9,13 @@ ExponentialBackoffJitterType, ExponentialRetryBackoffStrategy, RetryStrategyOptions, + RetryStrategyType, SimpleRetryToken, StandardRetryQuota, StandardRetryToken, ) from .interfaces.retries import RetryStrategy -RetryStrategyType = Literal["simple", "standard"] - class RetryStrategyResolver: """Retry strategy resolver that caches retry strategies based on configuration options. diff --git a/packages/smithy-core/src/smithy_core/interfaces/retries.py b/packages/smithy-core/src/smithy_core/interfaces/retries.py index cff7cb498..e43367cb7 100644 --- a/packages/smithy-core/src/smithy_core/interfaces/retries.py +++ b/packages/smithy-core/src/smithy_core/interfaces/retries.py @@ -46,7 +46,7 @@ def compute_next_backoff_delay(self, retry_attempt: int) -> float: @dataclass(kw_only=True) class RetryToken(Protocol): - """Token issued by a :py:class:`RetryStrategy` for the next attempt.""" + """Token issued by a :py:class:`smithy_core.aio.interfaces.retries.RetryStrategy` for the next attempt.""" retry_count: int """Retry count is the total number of attempts minus the initial attempt."""