Add a timeout in requests.get()

This commit is contained in:
Dor Askayo 2022-09-07 22:35:09 +03:00
parent 0fde8febf9
commit 43a8cc6b50
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())