Skip to content

Commit

Permalink
README housekeeping and timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
dvershinin committed Nov 9, 2024
1 parent a6b7d95 commit c092211
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog
All notable changes to this project will be documented in this file.

## [3.5.7] - 2024-11-07
### Fixed
* Raised files download timeout to 30 seconds

## [3.5.6] - 2024-09-08
### Fixed
* Known NGINX repo has been moved to GitHub
Expand Down
2 changes: 1 addition & 1 deletion src/lastversion/__about__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Package metadata"""

__version__ = "3.5.6"
__version__ = "3.5.7"
__self__ = "dvershinin/lastversion"
7 changes: 5 additions & 2 deletions src/lastversion/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utility functions for lastversion."""

import errno
import io
import logging
Expand Down Expand Up @@ -38,6 +39,8 @@
except ImportError:
pass

DOWNLOAD_TIMEOUT = 30

log = logging.getLogger(__name__)
content_disposition_regex = re.compile(
r"filename(?P<priority>\*)?=((?P<encoding>\S+)'')?(?P<filename>[^;]*)"
Expand Down Expand Up @@ -282,7 +285,7 @@ def download_file(url, local_filename=None):
local_filename = url.split("/")[-1]
try:
# Note that the stream=True parameter below
with requests.get(url, stream=True, timeout=5) as response:
with requests.get(url, stream=True, timeout=DOWNLOAD_TIMEOUT) as response:
response.raise_for_status()
if "." not in local_filename and "Content-Disposition" in response.headers:
disp_filename = get_content_disposition_filename(response)
Expand Down Expand Up @@ -419,7 +422,7 @@ def extract_file(url: str, to_dir="."):
log.critical("pip install py7zr to support .7z archives")
return
try:
with requests.get(url, stream=True, timeout=5) as response:
with requests.get(url, stream=True, timeout=DOWNLOAD_TIMEOUT) as response:
response.raise_for_status()
# Download the file in chunks and save it to a memory buffer
# content-length may be empty, default to 0
Expand Down

0 comments on commit c092211

Please sign in to comment.