MCPcopy
hub / github.com/urllib3/urllib3 / sleep

Method sleep

src/urllib3/util/retry.py:373–387  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 9

test_sleepMethod · 0.95
urlopenMethod · 0.80
sleep_for_retryMethod · 0.80
_sleep_backoffMethod · 0.80
slowFunction · 0.80
generateFunction · 0.80

Calls 2

sleep_for_retryMethod · 0.95
_sleep_backoffMethod · 0.95