Add a timeout in requests.get()
This commit is contained in:
parent
0fde8febf9
commit
43a8cc6b50
|
@ -101,7 +101,7 @@ this script the next time")
|
||||||
if not os.path.isfile(abs_file_name):
|
if not os.path.isfile(abs_file_name):
|
||||||
print(f"Downloading: {file_name}")
|
print(f"Downloading: {file_name}")
|
||||||
response = requests.get(url, allow_redirects=True, stream=True,
|
response = requests.get(url, allow_redirects=True, stream=True,
|
||||||
headers=headers)
|
headers=headers, timeout=20)
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
with open(abs_file_name, 'wb') as target_file:
|
with open(abs_file_name, 'wb') as target_file:
|
||||||
target_file.write(response.raw.read())
|
target_file.write(response.raw.read())
|
||||||
|
|
Loading…
Reference in New Issue