aistore.sdk.retry_manager

View as Markdown

Module Contents

Classes

NameDescription
RetryManagerManages applying the retry configuration along with any custom logic to requests.

Data

logger

API

class aistore.sdk.retry_manager.RetryManager(
executor: aistore.sdk.request_executor.RequestExecutor,
retry_config: typing.Optional[aistore.sdk.retry_config.RetryConfig] = None
)

Manages applying the retry configuration along with any custom logic to requests.

Parameters:

executor
RequestExecutor

Sends requests without a retry wrapper to the configured AIS endpoint

retry_config
Optional[RetryConfig]Defaults to None

Retry configuration, containing config for both tenacity retry logic and logic for cold gets from remote backend providers.

_lock_poller
_retry_config
= retry_config or RetryConfig.default()
_retrying
= self._build_retrying()
retry_config
RetryConfig

Return the retry config provided to this manager

aistore.sdk.retry_manager.RetryManager.__getstate__()
aistore.sdk.retry_manager.RetryManager.__setstate__(
state
)
aistore.sdk.retry_manager.RetryManager._before_sleep(
retry_state: tenacity.RetryCallState
)

Hook called by Tenacity before sleeping between retries. Determine if we want to delay the retry. If so, use LockPoller to poll until the object is unlocked.

Parameters:

retry_state
tenacity.RetryCallState

Retry state from tenacity.

aistore.sdk.retry_manager.RetryManager._build_retrying() -> tenacity.Retrying

Compose network_retry with the cold-get write-lock polling hook.

aistore.sdk.retry_manager.RetryManager._should_delay_retry(
exc: requests.ConnectionError,
req: requests.PreparedRequest
) -> bool
staticmethod

If we get a read timeout, it’s possible AIS is currently downloading and writing a remote object, so our initial request failed to acquire a read lock.

Retrying immediately means we expect AIS to be finished downloading from remote, which may take longer than our default retry.

Returns: Whether to delay tenacity retry.

Parameters:

exc
requests.ConnectionError

Original exception.

req
PreparedRequest

Validated request that produced exc.

aistore.sdk.retry_manager.RetryManager.with_retry(
request_func: typing.Callable[..., requests.Response],
args = (),
kwargs = {}
) -> requests.Response

Why tenacity.retry over urllib3.Retry? urllib3.Retry always retries the same failing URL, which is problematic if a target is down or restarting. Instead, we retry at this stage with tenacity to re-create the initial request to the proxy URL. This request will then get redirected to the latest selected target.

Parameters:

request_func
Callable

Function that makes a request to AIS and returns a requests.Response object.

*args
Defaults to ()

Args for request_func.

**kwargs
Defaults to {}

Kwargs for request_func.

Returns: Response

Response object from the provided request_func.

aistore.sdk.retry_manager.logger = utils.get_logger(__name__)