Skip to content

Commit

Permalink
Make max_retries and max_redirects not count the initial attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
ml31415 committed Apr 15, 2024
1 parent de87bf4 commit 9f2365d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/geventhttpclient/useragent.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,11 +434,11 @@ def urlopen(
params=params,
files=files,
)
for retry in range(self.max_retries):
for retry in range(self.max_retries + 1):
if retry > 0 and self.retry_delay:
# Don't wait the first time and skip if no delay specified
gevent.sleep(self.retry_delay)
for _ in range(self.max_redirects):
for _ in range(self.max_redirects + 1):
if self.cookiejar is not None:
self.cookiejar.add_cookie_header(req)

Expand Down Expand Up @@ -547,7 +547,7 @@ def download(self, url, fpath, chunk_size=16 * 1024, resume=False, **kwargs):
else:
offset = 0

for _ in range(self.max_retries):
for _ in range(self.max_retries + 1):
if offset:
headers["Range"] = f"bytes={offset}-"
resp = self.urlopen(url, headers=headers, **kwargs)
Expand Down

0 comments on commit 9f2365d

Please sign in to comment.