Is this method/status code 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
(
self, method: str, status_code: int, has_retry_after: bool = False
)
| 409 | return True |
| 410 | |
| 411 | def is_retry( |
| 412 | self, method: str, status_code: int, has_retry_after: bool = False |
| 413 | ) -> bool: |
| 414 | """Is this method/status code retryable? (Based on allowlists and control |
| 415 | variables such as the number of total retries to allow, whether to |
| 416 | respect the Retry-After header, whether this header is present, and |
| 417 | whether the returned status code is on the list of status codes to |
| 418 | be retried upon on the presence of the aforementioned header) |
| 419 | """ |
| 420 | if not self._is_method_retryable(method): |
| 421 | return False |
| 422 | |
| 423 | if self.status_forcelist and status_code in self.status_forcelist: |
| 424 | return True |
| 425 | |
| 426 | return bool( |
| 427 | self.total |
| 428 | and self.respect_retry_after_header |
| 429 | and has_retry_after |
| 430 | and (status_code in self.RETRY_AFTER_STATUS_CODES) |
| 431 | ) |
| 432 | |
| 433 | def is_exhausted(self) -> bool: |
| 434 | """Are we out of retries?""" |