Skip to content

Commit 6766d96

Browse files
authored
Add docstrings for _retry.py (#113)
1 parent 85a7b10 commit 6766d96

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/yandex_cloud_ml_sdk/_retry.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ async def _grpc_call(
260260

261261

262262
class UnaryUnaryRetryInterceptor(grpc.aio.UnaryUnaryClientInterceptor, RetrierBase):
263+
""":meta private:"""
263264
async def intercept_unary_unary(
264265
self,
265266
continuation: UnaryUnaryContinuationType,
@@ -284,6 +285,7 @@ async def intercept_unary_unary(
284285

285286

286287
class UnaryStreamRetryInterceptor(grpc.aio.UnaryStreamClientInterceptor, RetrierBase):
288+
""":meta private:"""
287289
async def intercept_unary_stream(
288290
self,
289291
# NB: look at UnaryStreamContinuationType comment above about type ignoring
@@ -317,17 +319,25 @@ async def intercept_unary_stream(
317319
# pylint: disable=too-many-instance-attributes
318320
@dataclass(frozen=True)
319321
class RetryPolicy:
322+
"""A class that defines a retry policy for network operations."""
323+
#: the maximum number of retry attempts
320324
max_attempts: int = 5
325+
#: the initial backoff time (in seconds)
321326
initial_backoff: float = 1.0
327+
#: the maximum backoff time (in seconds)
322328
max_backoff: float = 10.0
329+
#: the multiplier applied to the backoff after each attempt
323330
backoff_multiplier: float = 1.5
331+
#: the maximum amount of jitter to add to the backoff
324332
jitter: float = 1.0
333+
#: the grpc status codes that are considered retriable
325334
retriable_codes: Iterable[grpc.StatusCode] = (
326335
grpc.StatusCode.UNAVAILABLE,
327336
grpc.StatusCode.RESOURCE_EXHAUSTED
328337
)
329-
338+
#: :meta private:
330339
unary_unary_interceptor_class: type[UnaryUnaryRetryInterceptor] | None = UnaryUnaryRetryInterceptor
340+
#: :meta private:
331341
unary_stream_interceptor_class: type[UnaryStreamRetryInterceptor] | None = UnaryStreamRetryInterceptor
332342

333343
def get_interceptors(self) -> tuple[grpc.aio.ClientInterceptor, ...]:
@@ -351,8 +361,14 @@ async def sleep(self, attempt: int, deadline: float | None) -> None:
351361

352362

353363
class NoRetryPolicy(RetryPolicy):
364+
"""
365+
A retry policy that disables retries.
366+
367+
This class overrides the behavior of the base RetryPolicy to return no interceptors.
368+
"""
354369
def __init__(self):
355370
super().__init__()
356371

357372
def get_interceptors(self) -> tuple[()]:
373+
""":meta private:"""
358374
return ()

0 commit comments

Comments
 (0)