Return a new Retry object with incremented retry counters. :param response: A response object, or None, if the server did not return a response. :type response: :class:`~urllib3.response.BaseHTTPResponse` :param Exception error: An error encountered during the re
(
self,
method: str | None = None,
url: str | None = None,
response: BaseHTTPResponse | None = None,
error: Exception | None = None,
_pool: ConnectionPool | None = None,
_stacktrace: TracebackType | None = None,
)
| 450 | return min(retry_counts) < 0 |
| 451 | |
| 452 | def increment( |
| 453 | self, |
| 454 | method: str | None = None, |
| 455 | url: str | None = None, |
| 456 | response: BaseHTTPResponse | None = None, |
| 457 | error: Exception | None = None, |
| 458 | _pool: ConnectionPool | None = None, |
| 459 | _stacktrace: TracebackType | None = None, |
| 460 | ) -> Self: |
| 461 | class="st">"""Return a new Retry object with incremented retry counters. |
| 462 | |
| 463 | :param response: A response object, or None, if the server did not |
| 464 | return a response. |
| 465 | :type response: :class:`~urllib3.response.BaseHTTPResponse` |
| 466 | :param Exception error: An error encountered during the request, or |
| 467 | None if the response was received successfully. |
| 468 | |
| 469 | :return: A new ``Retry`` object. |
| 470 | class="st">""" |
| 471 | if self.total is False and error: |
| 472 | class="cm"># Disabled, indicate to re-raise the error. |
| 473 | raise reraise(type(error), error, _stacktrace) |
| 474 | |
| 475 | total = self.total |
| 476 | if total is not None: |
| 477 | total -= 1 |
| 478 | |
| 479 | connect = self.connect |
| 480 | read = self.read |
| 481 | redirect = self.redirect |
| 482 | status_count = self.status |
| 483 | other = self.other |
| 484 | cause = class="st">"unknown" |
| 485 | status = None |
| 486 | redirect_location = None |
| 487 | |
| 488 | if error and self._is_connection_error(error): |
| 489 | class="cm"># Connect retry? |
| 490 | if connect is False: |
| 491 | raise reraise(type(error), error, _stacktrace) |
| 492 | elif connect is not None: |
| 493 | connect -= 1 |
| 494 | |
| 495 | elif error and self._is_read_error(error): |
| 496 | class="cm"># Read retry? |
| 497 | if read is False or method is None or not self._is_method_retryable(method): |
| 498 | raise reraise(type(error), error, _stacktrace) |
| 499 | elif read is not None: |
| 500 | read -= 1 |
| 501 | |
| 502 | elif error: |
| 503 | class="cm"># Other retry? |
| 504 | if other is not None: |
| 505 | other -= 1 |
| 506 | |
| 507 | elif response and response.get_redirect_location(): |
| 508 | class="cm"># Redirect retry? |
| 509 | if redirect is not None: |