MCPcopy
hub / github.com/urllib3/urllib3 / Retry

Class Retry

src/urllib3/util/retry.py:41–553  ·  view source on GitHub ↗

Retry configuration. Each retry attempt will create a new Retry object with updated values, so they can be safely reused. Retries can be defined as a default for a pool: .. code-block:: python retries = Retry(connect=5, read=2, redirect=5) http = PoolManager(retri

Source from the content-addressed store, hash-verified

39
40
41class Retry:
42 """Retry configuration.
43
44 Each retry attempt will create a new Retry object with updated values, so
45 they can be safely reused.
46
47 Retries can be defined as a default for a pool:
48
49 .. code-block:: python
50
51 retries = Retry(connect=5, read=2, redirect=5)
52 http = PoolManager(retries=retries)
53 response = http.request("GET", "https://example.com/")
54
55 Or per-request (which overrides the default for the pool):
56
57 .. code-block:: python
58
59 response = http.request("GET", "https://example.com/", retries=Retry(10))
60
61 Retries can be disabled by passing ``False``:
62
63 .. code-block:: python
64
65 response = http.request("GET", "https://example.com/", retries=False)
66
67 Errors will be wrapped in :class:`~urllib3.exceptions.MaxRetryError` unless
68 retries are disabled, in which case the causing exception will be raised.
69
70 :param int total:
71 Total number of retries to allow. Takes precedence over other counts.
72
73 Set to ``None`` to remove this constraint and fall back on other
74 counts.
75
76 Set to ``0`` to fail on the first retry.
77
78 Set to ``False`` to disable and imply ``raise_on_redirect=False``.
79
80 :param int connect:
81 How many connection-related errors to retry on.
82
83 These are errors raised before the request is sent to the remote server,
84 which we assume has not triggered the server to process the request.
85
86 Set to ``0`` to fail on the first retry of this type.
87
88 :param int read:
89 How many times to retry on read errors.
90
91 These errors are raised after the request was sent to the server, so the
92 request may have side-effects.
93
94 Set to ``0`` to fail on the first retry of this type.
95
96 :param int redirect:
97 How many redirects to perform. Limit this to avoid infinite redirect
98 loops.

Callers 15

test_stringMethod · 0.90
test_retry_total_noneMethod · 0.90
test_retry_defaultMethod · 0.90
test_retry_otherMethod · 0.90
test_retry_read_zeroMethod · 0.90
test_status_counterMethod · 0.90
test_backoffMethod · 0.90

Calls

no outgoing calls

Tested by 15

test_stringMethod · 0.72
test_retry_total_noneMethod · 0.72
test_retry_defaultMethod · 0.72
test_retry_otherMethod · 0.72
test_retry_read_zeroMethod · 0.72
test_status_counterMethod · 0.72
test_backoffMethod · 0.72