Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-51: Fix module installation error with requests #52

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ufpy/github/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import Iterable
from zipfile import ZipFile

from requests import get
import requests

from ufpy.path import UOpen

Expand Down Expand Up @@ -62,7 +62,7 @@ def __init__(self, repo: str, base_download_path: str = CWD, branch_name: str =

def __enter__(self):
url = f'https://github.com/{self.__repo}/archive/{self.__branch}.zip'
r = get(url, timeout=10)
r = requests.get(url, timeout=10)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (performance): Consider adding a timeout to the requests.get call in the download_file method

For consistency with the enter method and to prevent hanging on slow connections, it might be beneficial to add a timeout parameter to this request as well.

Suggested change
r = requests.get(url, timeout=10)
r = requests.get(url, timeout=(5, 30))


if not r.ok:
r.raise_for_status()
Expand All @@ -85,7 +85,7 @@ def download_file(self, file_path: str, download_path: str = ''):
download_path = f'{self.__base_download_path}/{download_path}'

url = f'https://raw.githubusercontent.com/{self.__repo}/{self.__branch}/{file_path}'
r = get(url)
r = requests.get(url)

if not r.ok:
r.raise_for_status()
Expand Down