You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* added samples for timeout and retries
* added changes for separate throttle and connection retry kwargs
* added test_retry_policy_async and fixed pylint issue for cosmos clients
* marked test_retry_policy_async as cosmosQuery
* added in documentation for new throttle and config retries setup
* fixed async tests to use with client instead of asyncSetUp
* changing annotation to cosmosEmulator to cosmosQuery for testing
* made mockExecute functions async, removed part of test that was never supposed to be hit
* edited timeout and retries config
* changed marking to cosmosEmulator to see if it fails ci tests
* changed mf.counter to 1 to match sync test
* reset connectionRetryConfiguration in service_retry_policies_async
* created separate connection policy for async test
* edited test_default_retry_policy_for_create_async to use create_container_if_not_exists
* edited spacing
---------
Co-authored-by: Andrew Mathew <[email protected]>
The options for the resource throttle retry policy used for 429 error codes can be changed from the default client configurations with the options below. These are:
18
-
-`Retry Total`: Represents the total amount of retries. Can be changed by passing the `retry_total` option. Default value is 9.
30
+
-`Retry Throttle Total`: Represents the total amount of retries. Can be changed by passing the `retry_throttle_total` option. Default value is 9.
19
31
-`Retry Fixed Interval`: Represents a fixed wait period between retry attempts in seconds. Can be changed by passing the
20
32
`retry_fixed_interval` option (`float`). The default behaviour is to use an exponential retry policy. Must be a value >= 1.
21
-
-`Retry Backoff Max`: Represents the maximum retry wait time. Can be changed by passing the `retry_backoff_max` option. Default value is 30s.
33
+
-`Retry Throttle Backoff Max`: Represents the maximum retry wait time. Can be changed by passing the `retry_throttle_backoff_max` option. Default value is 30s.
22
34
35
+
Previously, `retry_total` and `retry_backoff_max` were used to set both the throttle and connection retry policy configurations.
36
+
This option is backwards compatible though, the option remains to set both throttle and connection retry configurations with the same `retry_total` and `retry_backoff_max` value.
37
+
38
+
In the example below the total number of throttle retries is 5, the fixed interval is set to 3 seconds, and the maximum throttle retry backoff wait time is 15 seconds.
39
+
This leaves the connection retry policies set to their default values.
The retry options below can be changed from the default client configurations. These are:
54
+
-`Retry Total`: Represents the total amount of retries. Can be changed by passing the `retry_total` option. Default value is 9.
27
55
-`Retry Connect`: Maximum number of connection error retry attempts. Can be changed by passing the `retry_connect` option. Default value is 3.
28
56
-`Retry Read`: Maximum number of socket read retry attempts. Can be changed by passing the `retry_read` option. Default value is 3.
29
-
-`Retry Status`: Maximum number of retry attempts on error status codes. Can be changed by passing the `retry_status` option. Default value is 3.
30
-
-`Retry On Status Codes`: A list of specific status codes to retry on. Can be changed by passing the `retry_on_status_codes` option. Default value is an empty list.
31
57
-`Retry Backoff Factor`: Factor to calculate wait time between retry attempts. Can be changed by passing the `retry_backoff_factor` option. Default value is 1.
58
+
-`Retry Backoff Max`: Represents the maximum retry wait time. Can be changed by passing the `retry_backoff_max` option. Default value is 30s.
59
+
60
+
61
+
In the example below, the maximum total retries is 7 attempts, the connection error retry is 5 attempts, and the socket read retry is 4 attempts.
62
+
The retry backoff factor is set to 2. When the retry backoff factor is 2, it means the wait time for retries will increase exponentially (1s, 2s, 4s, 8s, 16s...).
63
+
Lastly, the retry backoff max is 20, meaning that the maximum wait time between retries will be 20 seconds.
Additionally, in the above example the throttle retry total will be 7, and throttle max backoff will be 20 seconds.
74
+
75
+
76
+
To configure throttle and connection retries separately, both sets of parameters would need to be passed in as shown in the example below.
77
+
In this example, the connection retry backoff max time is 35 seconds, while setting the throttle backoff max to 25 seconds.
78
+
Additionally, the total throttle retry attempts is 5, while the total connection retry attempts is 10.
79
+
80
+
```python
81
+
from azure.cosmos import CosmosClient
82
+
83
+
import os
84
+
URL= os.environ['ACCOUNT_URI']
85
+
KEY= os.environ['ACCOUNT_KEY']
86
+
87
+
client = CosmosClient(URL, credential=KEY,
88
+
retry_backoff_max=35,
89
+
retry_throttle_backoff_max=25,
90
+
retry_throttle_total=5,
91
+
retry_total=10)
92
+
```
32
93
33
94
More information on the SDK's default retry behaviors can be found in our error codes and retries [document](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/cosmos/azure-cosmos/docs/ErrorCodesAndRetries.md).
0 commit comments