21 lines
585 B
Python
21 lines
585 B
Python
# Copyright 2026 Umbra Tools (umbratools.com)
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
from __future__ import annotations
|
|
|
|
import logging
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class RetryHandler:
|
|
def __init__(self, max_retries: int = 3, delay: float = 2.0) -> None:
|
|
self.max_retries = max_retries
|
|
self.delay = delay
|
|
|
|
def should_retry(self, attempt: int, error: Exception) -> bool:
|
|
if attempt < self.max_retries:
|
|
logger.warning("Retry %d/%d after error: %s", attempt + 1, self.max_retries, error)
|
|
return True
|
|
return False
|