Skip to content

Commit 1c1e3cb

Browse files
committed
Set 10sec default timeout to all HTTP requests
1 parent 028d206 commit 1c1e3cb

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

pioinstaller/python.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ def get_portable_python_url():
9696
systype = util.get_systype()
9797
result = requests.get(
9898
"https://api.registry.platformio.org/v3/packages/"
99-
"platformio/tool/python-portable"
99+
"platformio/tool/python-portable",
100+
timeout=10,
100101
).json()
101102
versions = [
102103
version

pioinstaller/util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ def safe_create_dir(path, raise_exception=False):
9090

9191
def download_file(url, dst, cache=True):
9292
if cache:
93-
content_length = requests.head(url).headers.get("Content-Length")
93+
content_length = requests.head(url, timeout=10).headers.get("Content-Length")
9494
if os.path.isfile(dst) and content_length == os.path.getsize(dst):
9595
log.debug("Getting from cache: %s", dst)
9696
return dst
9797

98-
resp = requests.get(url, stream=True)
98+
resp = requests.get(url, stream=True, timeout=10)
9999
itercontent = resp.iter_content(chunk_size=io.DEFAULT_BUFFER_SIZE)
100100
safe_create_dir(os.path.dirname(dst))
101101
with open(dst, "wb") as fp:

0 commit comments

Comments
 (0)