diff options
| author | Liora Milbaum <liora@lmb.co.il> | 2022-12-06 06:15:22 +0200 |
|---|---|---|
| committer | Nejc Habjan <hab.nejc@gmail.com> | 2022-12-06 09:53:48 +0100 |
| commit | 887852d7ef02bed6dff5204ace73d8e43a66e32f (patch) | |
| tree | 5f7afba429358d68c992fa793b9ee79bd20881bf | |
| parent | 985b971cf6d69692379805622a1bb1ff29ae308d (diff) | |
| download | gitlab-887852d7ef02bed6dff5204ace73d8e43a66e32f.tar.gz | |
refactor: Moving RETRYABLE_TRANSIENT_ERROR_CODES to const
| -rw-r--r-- | gitlab/client.py | 3 | ||||
| -rw-r--r-- | gitlab/const.py | 2 | ||||
| -rw-r--r-- | tests/unit/test_gitlab_http_methods.py | 2 |
3 files changed, 4 insertions, 3 deletions
diff --git a/gitlab/client.py b/gitlab/client.py index 8514ffd..5e1db0a 100644 --- a/gitlab/client.py +++ b/gitlab/client.py @@ -22,7 +22,6 @@ REDIRECT_MSG = ( "{source!r} to {target!r}" ) -RETRYABLE_TRANSIENT_ERROR_CODES = [500, 502, 503, 504] + list(range(520, 531)) # https://docs.gitlab.com/ee/api/#offset-based-pagination _PAGINATION_URL = ( @@ -781,7 +780,7 @@ class Gitlab: return result if (429 == result.status_code and obey_rate_limit) or ( - result.status_code in RETRYABLE_TRANSIENT_ERROR_CODES + result.status_code in gitlab.const.RETRYABLE_TRANSIENT_ERROR_CODES and retry_transient_errors ): # Response headers documentation: diff --git a/gitlab/const.py b/gitlab/const.py index 1dab752..5d3602b 100644 --- a/gitlab/const.py +++ b/gitlab/const.py @@ -131,6 +131,8 @@ SEARCH_SCOPE_PROJECT_NOTES = SearchScope.PROJECT_NOTES.value USER_AGENT: str = f"{__title__}/{__version__}" +RETRYABLE_TRANSIENT_ERROR_CODES = [500, 502, 503, 504] + list(range(520, 531)) + __all__ = [ "AccessLevel", "Visibility", diff --git a/tests/unit/test_gitlab_http_methods.py b/tests/unit/test_gitlab_http_methods.py index 252ecb6..d4abe0b 100644 --- a/tests/unit/test_gitlab_http_methods.py +++ b/tests/unit/test_gitlab_http_methods.py @@ -6,7 +6,7 @@ import requests import responses from gitlab import GitlabHttpError, GitlabList, GitlabParsingError, RedirectError -from gitlab.client import RETRYABLE_TRANSIENT_ERROR_CODES +from gitlab.const import RETRYABLE_TRANSIENT_ERROR_CODES from tests.unit import helpers |
