Merge pull request #192 from doraskayo/requests-timeout

Add a timeout in requests.get()
This commit is contained in:
Andrius Štikonas 2022-09-07 20:45:46 +01:00 committed by GitHub
commit 7f3e07d166
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -101,7 +101,7 @@ this script the next time")
if not os.path.isfile(abs_file_name):
print(f"Downloading: {file_name}")
response = requests.get(url, allow_redirects=True, stream=True,
headers=headers)
headers=headers, timeout=20)
if response.status_code == 200:
with open(abs_file_name, 'wb') as target_file:
target_file.write(response.raw.read())