-
Notifications
You must be signed in to change notification settings - Fork 235
/
azure.core.pipeline.policies.RetryPolicy.yml
332 lines (302 loc) · 12.2 KB
/
azure.core.pipeline.policies.RetryPolicy.yml
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
### YamlMime:PythonClass
uid: azure.core.pipeline.policies.RetryPolicy
name: RetryPolicy
fullName: azure.core.pipeline.policies.RetryPolicy
module: azure.core.pipeline.policies
inheritances:
- azure.core.pipeline.policies._retry.RetryPolicyBase
- azure.core.pipeline.policies._base.HTTPPolicy
summary: 'A retry policy.
The retry policy in the pipeline can be configured directly, or tweaked on a per-call
basis.'
constructor:
syntax: 'RetryPolicy(**kwargs: Any)'
keywordOnlyParameters:
- name: retry_total
description: 'Total number of retries to allow. Takes precedence over other counts.
Default value is 10.'
types:
- <xref:int>
- name: retry_connect
description: 'How many connection-related errors to retry on.
These are errors raised before the request is sent to the remote server,
which we assume has not triggered the server to process the request. Default
value is 3.'
types:
- <xref:int>
- name: retry_read
description: 'How many times to retry on read errors.
These errors are raised after the request was sent to the server, so the
request may have side-effects. Default value is 3.'
types:
- <xref:int>
- name: retry_status
description: How many times to retry on bad status codes. Default value is 3.
types:
- <xref:int>
- name: retry_backoff_factor
description: 'A backoff factor to apply between attempts after the second try
(most errors are resolved immediately by a second try without a delay).
In fixed mode, retry policy will always sleep for {backoff factor}.
In ''exponential'' mode, retry policy will sleep for: *{backoff factor} * (2
** ({number of total retries} - 1))*
seconds. If the backoff_factor is 0.1, then the retry will sleep
for [0.0s, 0.2s, 0.4s, ...] between retries. The default value is 0.8.'
types:
- <xref:float>
- name: retry_backoff_max
description: The maximum back off time. Default value is 120 seconds (2 minutes).
types:
- <xref:int>
- name: retry_mode
description: Fixed or exponential delay between attemps, default is exponential.
types:
- <xref:azure.core.pipeline.policies.RetryMode>
- name: timeout
description: Timeout setting for the operation in seconds, default is 604800s
(7 days).
types:
- <xref:int>
examples:
- "Configuring a retry policy.<!--[!code-python[Main](les\\test_example_sync.py )]-->\n\
\n<!-- literal_block {\"ids\": [], \"classes\": [], \"names\": [], \"dupnames\"\
: [], \"backrefs\": [], \"source\": \"C:\\\\hostedtoolcache\\\\windows\\\\Python\\\
\\3.11.9\\\\x64\\\\Lib\\\\site-packages\\\\py2docfx\\\\dist_temp\\\\35\\\\azure-core-1.30.2\\\
\\samples\\\\test_example_sync.py\", \"xml:space\": \"preserve\", \"force\": false,\
\ \"language\": \"python\", \"highlight_args\": {\"linenostart\": 1}, \"linenos\"\
: false} -->\n\n````python\n\n from azure.core.pipeline.policies import RetryPolicy\n\
\n retry_policy = RetryPolicy()\n\n # Total number of retries to allow. Takes\
\ precedence over other counts.\n # Default value is 10.\n retry_policy.total_retries\
\ = 5\n\n # How many connection-related errors to retry on.\n # These are errors\
\ raised before the request is sent to the remote server,\n # which we assume\
\ has not triggered the server to process the request. Default value is 3\n retry_policy.connect_retries\
\ = 2\n\n # How many times to retry on read errors.\n # These errors are raised\
\ after the request was sent to the server, so the\n # request may have side-effects.\
\ Default value is 3.\n retry_policy.read_retries = 4\n\n # How many times to\
\ retry on bad status codes. Default value is 3.\n retry_policy.status_retries\
\ = 3\n\n # A backoff factor to apply between attempts after the second try\n\
\ # (most errors are resolved immediately by a second try without a delay).\n\
\ # Retry policy will sleep for:\n # {backoff factor} * (2 ** ({number of\
\ total retries} - 1))\n # seconds. If the backoff_factor is 0.1, then the retry\
\ will sleep\n # for [0.0s, 0.2s, 0.4s, ...] between retries.\n # The default\
\ value is 0.8.\n retry_policy.backoff_factor = 0.5\n\n # The maximum back off\
\ time. Default value is 120 seconds (2 minutes).\n retry_policy.backoff_max =\
\ 120\n\n # Alternatively you can disable redirects entirely\n retry_policy\
\ = RetryPolicy.no_retries()\n\n # All of these settings can also be configured\
\ per operation.\n policies.append(retry_policy)\n client: PipelineClient[HttpRequest,\
\ HttpResponse] = PipelineClient(base_url=url, policies=policies)\n request =\
\ HttpRequest(\"GET\", url)\n pipeline_response = client._pipeline.run(\n \
\ request,\n retry_total=10,\n retry_connect=1,\n retry_read=1,\n\
\ retry_status=5,\n retry_backoff_factor=0.5,\n retry_backoff_max=120,\n\
\ retry_on_methods=[\"GET\"],\n )\n\n ````\n"
methods:
- uid: azure.core.pipeline.policies.RetryPolicy.configure_retries
name: configure_retries
summary: Configures the retry settings.
signature: 'configure_retries(options: Dict[str, Any]) -> Dict[str, Any]'
parameters:
- name: options
description: keyword arguments from context.
isRequired: true
types:
- <xref:dict>
return:
description: A dict containing settings and history for retries.
types:
- <xref:dict>
- uid: azure.core.pipeline.policies.RetryPolicy.get_backoff_time
name: get_backoff_time
summary: Returns the current backoff time.
signature: 'get_backoff_time(settings: Dict[str, Any]) -> float'
parameters:
- name: settings
description: The retry settings.
isRequired: true
types:
- <xref:dict>
return:
description: The current backoff value.
types:
- <xref:float>
- uid: azure.core.pipeline.policies.RetryPolicy.get_retry_after
name: get_retry_after
summary: Get the value of Retry-After in seconds.
signature: 'get_retry_after(response: PipelineResponse[Any, AllHttpResponseType])
-> float | None'
parameters:
- name: response
description: The PipelineResponse object
isRequired: true
types:
- <xref:azure.core.pipeline.PipelineResponse>
return:
description: Value of Retry-After in seconds.
types:
- <xref:float>
- <xref:None>
- uid: azure.core.pipeline.policies.RetryPolicy.increment
name: increment
summary: Increment the retry counters.
signature: 'increment(settings: Dict[str, Any], response: PipelineRequest[HTTPRequestType]
| PipelineResponse[HTTPRequestType, AllHttpResponseType] | None = None, error:
Exception | None = None) -> bool'
parameters:
- name: settings
description: The retry settings.
isRequired: true
types:
- <xref:dict>
- name: response
description: A pipeline response object.
defaultValue: None
types:
- <xref:azure.core.pipeline.PipelineResponse>
- name: error
description: 'An error encountered during the request, or
None if the response was received successfully.'
defaultValue: None
types:
- <xref:azure.core.exceptions.AzureError>
return:
description: 'Whether any retry attempt is available
True if more retry attempts available, False otherwise'
types:
- <xref:bool>
- uid: azure.core.pipeline.policies.RetryPolicy.is_exhausted
name: is_exhausted
summary: Checks if any retries left.
signature: 'is_exhausted(settings: Dict[str, Any]) -> bool'
parameters:
- name: settings
description: the retry settings
isRequired: true
types:
- <xref:dict>
return:
description: False if have more retries. True if retries exhausted.
types:
- <xref:bool>
- uid: azure.core.pipeline.policies.RetryPolicy.is_retry
name: is_retry
summary: 'Checks if method/status code is retryable.
Based on allowlists and control variables such as the number of
total retries to allow, whether to respect the Retry-After header,
whether this header is present, and whether the returned status
code is on the list of status codes to be retried upon on the
presence of the aforementioned header.
The behavior is:
- If status_code < 400: don''t retry
- Else if Retry-After present: retry
- Else: retry based on the safe status code list ([408, 429, 500, 502, 503,
504])'
signature: 'is_retry(settings: Dict[str, Any], response: PipelineResponse[HTTPRequestType,
AllHttpResponseType]) -> bool'
parameters:
- name: settings
description: The retry settings.
isRequired: true
types:
- <xref:dict>
- name: response
description: The PipelineResponse object
isRequired: true
types:
- <xref:azure.core.pipeline.PipelineResponse>
return:
description: True if method/status code is retryable. False if not retryable.
types:
- <xref:bool>
- uid: azure.core.pipeline.policies.RetryPolicy.no_retries
name: no_retries
summary: Disable retries.
signature: no_retries() -> ClsRetryPolicy
return:
description: A retry policy with retries disabled.
types:
- <xref:azure.core.pipeline.policies.RetryPolicy>
- <xref:azure.core.pipeline.policies.AsyncRetryPolicy>
- uid: azure.core.pipeline.policies.RetryPolicy.parse_retry_after
name: parse_retry_after
summary: Helper to parse Retry-After and get value in seconds.
signature: 'parse_retry_after(retry_after: str) -> float'
parameters:
- name: retry_after
description: Retry-After header
isRequired: true
types:
- <xref:str>
return:
description: Value of Retry-After in seconds.
types:
- <xref:float>
- uid: azure.core.pipeline.policies.RetryPolicy.send
name: send
summary: Sends the PipelineRequest object to the next policy. Uses retry settings
if necessary.
signature: 'send(request: PipelineRequest[HTTPRequestType]) -> PipelineResponse[HTTPRequestType,
HTTPResponseType]'
parameters:
- name: request
description: The PipelineRequest object
isRequired: true
types:
- <xref:azure.core.pipeline.PipelineRequest>
return:
description: Returns the PipelineResponse or raises error if maximum retries exceeded.
types:
- <xref:azure.core.pipeline.PipelineResponse>
exceptions:
- type: azure.core.exceptions.AzureError if maximum retries exceeded.
- type: azure.core.exceptions.ClientAuthenticationError if authentication
- uid: azure.core.pipeline.policies.RetryPolicy.sleep
name: sleep
summary: 'Sleep between retry attempts.
This method will respect a server''s `Retry-After` response header
and sleep the duration of the time requested. If that is not present, it
will use an exponential backoff. By default, the backoff factor is 0 and
this method will return immediately.'
signature: 'sleep(settings: Dict[str, Any], transport: HttpTransport[HTTPRequestType,
HTTPResponseType], response: PipelineResponse[HTTPRequestType, HTTPResponseType]
| None = None) -> None'
parameters:
- name: settings
description: The retry settings.
isRequired: true
types:
- <xref:dict>
- name: transport
description: The HTTP transport type.
isRequired: true
types:
- <xref:azure.core.pipeline.transport.HttpTransport>
- name: response
description: The PipelineResponse object.
defaultValue: None
types:
- <xref:azure.core.pipeline.PipelineResponse>
- uid: azure.core.pipeline.policies.RetryPolicy.update_context
name: update_context
summary: Updates retry history in pipeline context.
signature: 'update_context(context: PipelineContext, retry_settings: Dict[str, Any])
-> None'
parameters:
- name: context
description: The pipeline context.
isRequired: true
types:
- <xref:azure.core.pipeline.PipelineContext>
- name: retry_settings
description: The retry settings.
isRequired: true
types:
- <xref:dict>
attributes:
- uid: azure.core.pipeline.policies.RetryPolicy.BACKOFF_MAX
name: BACKOFF_MAX
summary: Maximum backoff time.
signature: BACKOFF_MAX = 120
- uid: azure.core.pipeline.policies.RetryPolicy.next
name: next
summary: Pointer to the next policy or a transport (wrapped as a policy). Will be
set at pipeline creation.
signature: 'next: HTTPPolicy[HTTPRequestType, HTTPResponseType]'