|
46 | 46 |
|
47 | 47 | Download = namedtuple("Download", "uri directory filename path size sha1 md5") |
48 | 48 |
|
| 49 | +# Time (in seconds) to wait for the server to send data before giving up. |
| 50 | +# The ``REQUEST_CONNECTION_TIMEOUT`` defines: |
| 51 | +# - Connect timeout: The maximum time to wait for the client to establish a connection |
| 52 | +# to the server. |
| 53 | +# - Read timeout: The maximum time to wait for a server response once the connection |
| 54 | +# is established. |
| 55 | +# Notes: Use caution when lowering this value, as some servers |
| 56 | +# (e.g., https://cdn.kernel.org/) may take longer to respond to HTTP requests under |
| 57 | +# certain conditions. |
| 58 | +HTTP_REQUEST_TIMEOUT = 30 |
| 59 | + |
49 | 60 |
|
50 | 61 | def run_command_safely(command_args): |
51 | 62 | """ |
@@ -107,7 +118,7 @@ def fetch_http(uri, to=None): |
107 | 118 | path. |
108 | 119 | """ |
109 | 120 | request_session = get_request_session(uri) |
110 | | - response = request_session.get(uri, timeout=5) |
| 121 | + response = request_session.get(uri, timeout=HTTP_REQUEST_TIMEOUT) |
111 | 122 |
|
112 | 123 | if response.status_code != 200: |
113 | 124 | raise requests.RequestException |
@@ -416,7 +427,7 @@ def check_urls_availability(urls): |
416 | 427 |
|
417 | 428 | request_session = get_request_session(url) |
418 | 429 | try: |
419 | | - response = request_session.head(url, timeout=5) |
| 430 | + response = request_session.head(url, timeout=HTTP_REQUEST_TIMEOUT) |
420 | 431 | response.raise_for_status() |
421 | 432 | except requests.exceptions.RequestException: |
422 | 433 | errors.append(url) |
|
0 commit comments