|
9 | 9 |
|
10 | 10 | class RetryHandler(BaseMiddleware): |
11 | 11 | """ |
12 | | - TransportAdapter that allows us to specify the |
13 | | - retry policy for all requests |
| 12 | + TransportAdapter that allows us to specify the retry policy for all requests |
| 13 | +
|
| 14 | + Retry configuration. |
| 15 | +
|
| 16 | + :param int max_retries: |
| 17 | + Maximum number of retries to allow. Takes precedence over other counts. |
| 18 | + Set to ``0`` to fail on the first retry. |
| 19 | + :param iterable allowed_methods: |
| 20 | + Set of uppercased HTTP method verbs that we should retry on. |
| 21 | + By default, we only retry on methods which are considered to be |
| 22 | + idempotent (multiple requests with the same parameters end with the |
| 23 | + same state). See :attr:`Retry.DEFAULT_ALLOWED_METHODS`. |
| 24 | + Set to a ``None`` value to retry on any verb. |
| 25 | + :param iterable retry_on_status_codes: |
| 26 | + A set of integer HTTP status codes that we should force a retry on. |
| 27 | + A retry is initiated if the request method is in ``allowed_methods`` |
| 28 | + and the response status code is in ``RETRY STATUS CODES``. |
| 29 | + :param float retry_backoff_factor: |
| 30 | + A backoff factor to apply between attempts after the second try |
| 31 | + (most errors are resolved immediately by a second try without a |
| 32 | + delay). |
| 33 | + The request will sleep for:: |
| 34 | + {backoff factor} * (2 ** ({retry number} - 1)) |
| 35 | + seconds. If the backoff_factor is 0.1, then :func:`.sleep` will sleep |
| 36 | + for [0.0s, 0.2s, 0.4s, ...] between retries. It will never be longer |
| 37 | + than :attr:`RetryHandler.MAXIMUM_BACKOFF`. |
| 38 | + By default, backoff is set to 0.5. |
| 39 | + :param int retry_time_limit: |
| 40 | + The maximum cumulative time in seconds that total retries should take. |
| 41 | + The cumulative retry time and retry-after value for each request retry |
| 42 | + will be evaluated against this value; if the cumulative retry time plus |
| 43 | + the retry-after value is greater than the retry_time_limit, the failed |
| 44 | + response will be immediately returned, else the request retry continues. |
14 | 45 | """ |
15 | 46 |
|
16 | 47 | DEFAULT_MAX_RETRIES = 3 |
|
0 commit comments