(url: str, *, timeout: float, referer: Optional[str] = None)
| 246 | |
| 247 | if Retry is not None and HTTP_RETRY_TOTAL > 0: |
| 248 | retry = Retry( |
| 249 | total=HTTP_RETRY_TOTAL, |
| 250 | connect=HTTP_RETRY_TOTAL, |
| 251 | read=HTTP_RETRY_TOTAL, |
| 252 | status=HTTP_RETRY_TOTAL, |
| 253 | backoff_factor=HTTP_RETRY_BACKOFF, |
| 254 | allowed_methods=frozenset({"GET", "HEAD"}), |
| 255 | status_forcelist=(408, 425, 429, 500, 502, 503, 504, 520, 521, 522, 524), |
| 256 | respect_retry_after_header=True, |
| 257 | raise_on_status=False, |
| 258 | ) |
| 259 | adapter = HTTPAdapter(max_retries=retry) |
| 260 | session.mount("http://", adapter) |
| 261 | session.mount("https://", adapter) |
| 262 | |
| 263 | return session |
no test coverage detected