Skip to content

Commit 2b68c53

Browse files
committed
Also retry HTTP-based transient errors.
1 parent 5a1678f commit 2b68c53

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

gitlab/client.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -609,18 +609,29 @@ def http_request(
609609
prepped.url, {}, streamed, verify, None
610610
)
611611

612+
retry_transient_errors = kwargs.get(
613+
"retry_transient_errors", self.retry_transient_errors
614+
)
612615
cur_retries = 0
613616
while True:
614-
result = self.session.send(prepped, timeout=timeout, **settings)
617+
try:
618+
result = self.session.send(prepped, timeout=timeout, **settings)
619+
except requests.RequestException:
620+
if retry_transient_errors and (
621+
max_retries == -1 or cur_retries < max_retries
622+
):
623+
wait_time = 2 ** cur_retries * 0.1
624+
cur_retries += 1
625+
time.sleep(wait_time)
626+
continue
627+
628+
raise
615629

616630
self._check_redirects(result)
617631

618632
if 200 <= result.status_code < 300:
619633
return result
620634

621-
retry_transient_errors = kwargs.get(
622-
"retry_transient_errors", self.retry_transient_errors
623-
)
624635
if (429 == result.status_code and obey_rate_limit) or (
625636
result.status_code in [500, 502, 503, 504] and retry_transient_errors
626637
):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy