Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions designs/retries.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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."
}
"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`."
}
5 changes: 2 additions & 3 deletions packages/smithy-core/src/smithy_core/aio/retries.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
# 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
from ..retries import (
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
Loading