mcp_registry_client.retry
Retry logic for network requests.
RetryStrategy
Retry strategy for network requests.
Source code in mcp_registry_client/retry.py
__init__(config)
Initialize retry strategy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ClientConfig
|
Client configuration with retry settings |
required |
Source code in mcp_registry_client/retry.py
get_delay(attempt)
Calculate delay before next retry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attempt
|
int
|
Current attempt number (0-based) |
required |
Returns:
| Type | Description |
|---|---|
float
|
Delay in seconds |
should_retry(attempt, exception)
Determine if a request should be retried.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attempt
|
int
|
Current attempt number (0-based) |
required |
exception
|
Exception
|
The exception that occurred |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the request should be retried |
Source code in mcp_registry_client/retry.py
with_retry(func, strategy, operation_name='operation')
async
Execute an async function with retry logic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable[[], Awaitable[T]]
|
Async function to execute |
required |
strategy
|
RetryStrategy
|
Retry strategy to use |
required |
operation_name
|
str
|
Name of the operation for logging |
'operation'
|
Returns:
| Type | Description |
|---|---|
T
|
Result of the function call |
Raises:
| Type | Description |
|---|---|
Exception
|
The last exception if all retries are exhausted |