-
Notifications
You must be signed in to change notification settings - Fork 200
Expand file tree
/
Copy path_retry.py
More file actions
79 lines (54 loc) · 2.01 KB
/
Copy path_retry.py
File metadata and controls
79 lines (54 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: Copyright (c) 2024 Development Seed
from datetime import timedelta
from typing import TypedDict
class BackoffConfig(TypedDict, total=False):
"""Exponential backoff with jitter.
See `Exponential Backoff and Jitter <https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/>`_.
"""
init_backoff: timedelta
"""The initial backoff duration.
Defaults to 100 milliseconds.
"""
max_backoff: timedelta
"""The maximum backoff duration.
Defaults to 15 seconds.
"""
base: int | float
"""The base of the exponential to use.
Defaults to ``2``.
"""
class RetryConfig(TypedDict, total=False):
"""The configuration for how to respond to request errors.
The following categories of error will be retried:
* 5xx server errors
* Connection errors
* Dropped connections
* Timeouts for `safe <https://datatracker.ietf.org/doc/html/rfc7231#section-4.2.1>`_ / read-only requests
Requests will be retried up to some limit, using exponential
backoff with jitter. See :class:`~vortex.store.BackoffConfig` for
more information.
"""
backoff: BackoffConfig
"""The backoff configuration.
Defaults to the values listed above if not provided.
"""
max_retries: int
"""
The maximum number of times to retry a request
Set to 0 to disable retries.
Defaults to 10.
"""
retry_timeout: timedelta
"""
The maximum length of time from the initial request
after which no further retries will be attempted
This not only bounds the length of time before a server
error will be surfaced to the application, but also bounds
the length of time a request's credentials must remain valid.
As requests are retried without renewing credentials or
regenerating request payloads, this number should be kept
below 5 minutes to avoid errors due to expired credentials
and/or request payloads.
Defaults to 3 minutes.
"""