diff options
| author | Max Wittig <max.wittig95@gmail.com> | 2019-12-13 06:34:50 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-13 06:34:50 +0100 |
| commit | 36bbd37e6a79c6fd5e9b4d64119eda7812364387 (patch) | |
| tree | 088ed4f9e550dc6a18e8ef08f7f003a44ec58005 /gitlab/__init__.py | |
| parent | 3e2d69417aa8c6b043ee99fea5f8d7e31a2ba3e8 (diff) | |
| parent | 59fe2714741133989a7beed613f1eeb67c18c54e (diff) | |
| download | gitlab-36bbd37e6a79c6fd5e9b4d64119eda7812364387.tar.gz | |
Merge pull request #972 from mitar/http-retry
Retry transient HTTP errors
Diffstat (limited to 'gitlab/__init__.py')
| -rw-r--r-- | gitlab/__init__.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gitlab/__init__.py b/gitlab/__init__.py index 3605b80..09b7b81 100644 --- a/gitlab/__init__.py +++ b/gitlab/__init__.py @@ -518,6 +518,8 @@ class Gitlab(object): # obey the rate limit by default obey_rate_limit = kwargs.get("obey_rate_limit", True) + # do not retry transient errors by default + retry_transient_errors = kwargs.get("retry_transient_errors", False) # set max_retries to 10 by default, disable by setting it to -1 max_retries = kwargs.get("max_retries", 10) @@ -531,7 +533,9 @@ class Gitlab(object): if 200 <= result.status_code < 300: return result - if 429 == result.status_code and obey_rate_limit: + if (429 == result.status_code and obey_rate_limit) or ( + result.status_code in [500, 502, 503, 504] and retry_transient_errors + ): if max_retries == -1 or cur_retries < max_retries: wait_time = 2 ** cur_retries * 0.1 if "Retry-After" in result.headers: |
