fix(session): log "Retrying" only when a retry follows

A per-call max_retries=0 logged "Retrying... (1/0)" before raising, and the last of the default retries logged "(6/5)".
This commit is contained in:
imSp4rky
2026-10-15 14:48:20 -06:00
parent a4ce70a53c
commit 89f433963a
2 changed files with 32 additions and 7 deletions
+3 -7
View File
@@ -835,19 +835,15 @@ class RnetSession:
if response.status_code not in self.status_forcelist:
return response
last_exception = HTTPError(f"Received status code: {response.status_code}", response=response)
self.log.warning(
f"{response.status_code} {response.reason}({urlparse(url).path}). Retrying... "
f"({attempt + 1}/{max_retries})"
)
failure = f"{response.status_code} {response.reason}"
except self.catch_exceptions as e:
last_exception = e
response = None
self.log.warning(
f"{e.__class__.__name__}({urlparse(url).path}). Retrying... ({attempt + 1}/{max_retries})"
)
failure = e.__class__.__name__
if attempt < max_retries:
self.log.warning(f"{failure}({urlparse(url).path}). Retrying... ({attempt + 1}/{max_retries})")
if sleep_duration := self.get_sleep_time(response, attempt + 1):
if sleep_duration > 0:
time.sleep(sleep_duration)