MCPcopy
hub / github.com/urllib3/urllib3 / increment

Method increment

src/urllib3/util/retry.py:452–547  ·  src/urllib3/util/retry.py::Retry.increment

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,
    )

Source from the content-addressed store, hash-verified

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:

Callers 15

test_stringMethod · 0.95
test_retry_total_noneMethod · 0.95
test_retry_defaultMethod · 0.95
test_retry_otherMethod · 0.95
test_retry_read_zeroMethod · 0.95
test_status_counterMethod · 0.95
test_backoffMethod · 0.95
test_backoff_jitterMethod · 0.95

Calls 10

_is_connection_errorMethod · 0.95
_is_read_errorMethod · 0.95
_is_method_retryableMethod · 0.95
newMethod · 0.95
reraiseFunction · 0.85
RequestHistoryClass · 0.85
ResponseErrorClass · 0.85
MaxRetryErrorClass · 0.85
is_exhaustedMethod · 0.80
get_redirect_locationMethod · 0.45

Tested by 15

test_stringMethod · 0.76
test_retry_total_noneMethod · 0.76
test_retry_defaultMethod · 0.76
test_retry_otherMethod · 0.76
test_retry_read_zeroMethod · 0.76
test_status_counterMethod · 0.76
test_backoffMethod · 0.76
test_backoff_jitterMethod · 0.76