removed with_retry
This commit is contained in:
@@ -41,39 +41,6 @@ class FaceDetectionProgressReporter(Protocol):
|
||||
def emit_progress(self, payload: dict) -> None: ...
|
||||
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
|
||||
def with_retry(
|
||||
func: Callable[[], T],
|
||||
*,
|
||||
max_attempts: int,
|
||||
on: tuple[type[Exception], ...],
|
||||
escalate: type[AareException] | None = None,
|
||||
escalate_message: str | None = None,
|
||||
escalate_critical: bool | None = None,
|
||||
) -> T:
|
||||
attempts = max(1, int(max_attempts))
|
||||
last_error: Exception | None = None
|
||||
for _ in range(attempts):
|
||||
try:
|
||||
return func()
|
||||
except on as error:
|
||||
last_error = error
|
||||
|
||||
if escalate is not None:
|
||||
kwargs: dict[str, bool] = {}
|
||||
if escalate_critical is not None:
|
||||
kwargs["critical"] = escalate_critical
|
||||
message = escalate_message or str(last_error)
|
||||
raise escalate(message, **kwargs) from last_error
|
||||
|
||||
if last_error is not None:
|
||||
raise last_error
|
||||
|
||||
raise RuntimeError("with_retry exhausted without a captured exception")
|
||||
|
||||
|
||||
@dataclass
|
||||
class DAQRuntimeState:
|
||||
sample_provider: SampleProvider
|
||||
|
||||
Reference in New Issue
Block a user