Skip to content

Commit

Permalink
tentative to stabilise the request connection with a dedicated sessio…
Browse files Browse the repository at this point in the history
…n with a retry
  • Loading branch information
hadrilec committed Jan 1, 2025
1 parent 00f5a35 commit 3033ab5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pynsee/download/_download_pb.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

from pynsee.utils.requests_params import _get_requests_proxies
from pynsee.utils.requests_params import _get_requests_proxies, _get_requests_session


def _download_pb(url: str, fname: str, total: int = None):
Expand All @@ -19,8 +19,10 @@ def _download_pb(url: str, fname: str, total: int = None):
"""

proxies = _get_requests_proxies()
session = _get_requests_session()

resp = requests.get(url, proxies=proxies, stream=True, verify=False)
with session as s:
resp = s.get(url, proxies=proxies, stream=True, verify=False)

if total is None:
total = int(resp.headers.get("content-length", 0))
Expand Down

0 comments on commit 3033ab5

Please sign in to comment.