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
(self, response: BaseHTTPResponse | None = None)
| 371 | time.sleep(backoff) |
| 372 | |
| 373 | def sleep(self, response: BaseHTTPResponse | None = None) -> None: |
| 374 | """Sleep between retry attempts. |
| 375 | |
| 376 | This method will respect a server's ``Retry-After`` response header |
| 377 | and sleep the duration of the time requested. If that is not present, it |
| 378 | will use an exponential backoff. By default, the backoff factor is 0 and |
| 379 | this method will return immediately. |
| 380 | """ |
| 381 | |
| 382 | if self.respect_retry_after_header and response: |
| 383 | slept = self.sleep_for_retry(response) |
| 384 | if slept: |
| 385 | return |
| 386 | |
| 387 | self._sleep_backoff() |
| 388 | |
| 389 | def _is_connection_error(self, err: Exception) -> bool: |
| 390 | """Errors when we're fairly sure that the server did not receive the |