diff options
author | Nejc Habjan <nejc.habjan@siemens.com> | 2022-04-14 11:43:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-14 11:43:55 +0200 |
commit | 07a16af33c6d1965dae860d1e604ce36e42d8d87 (patch) | |
tree | 48788bfebd132d3363bc46fa16a6f44ab4f98537 | |
parent | 69ace2dcf41a763b624079e57805c1ba09865312 (diff) | |
parent | 7beb20ff7b7b85fb92fc6b647d9c1bdb7568f27c (diff) | |
download | gitlab-07a16af33c6d1965dae860d1e604ce36e42d8d87.tar.gz |
Merge pull request #1974 from Sineaggi/add-chunked-to-list-of-retryable-exceptions
Add ChunkedEncodingError to list of retryable exceptions
-rw-r--r-- | gitlab/client.py | 2 | ||||
-rw-r--r-- | tests/unit/test_gitlab_http_methods.py | 13 |
2 files changed, 12 insertions, 3 deletions
diff --git a/gitlab/client.py b/gitlab/client.py index 73a0a5c..0f61a17 100644 --- a/gitlab/client.py +++ b/gitlab/client.py @@ -701,7 +701,7 @@ class Gitlab: stream=streamed, **opts, ) - except requests.ConnectionError: + except (requests.ConnectionError, requests.exceptions.ChunkedEncodingError): if retry_transient_errors and ( max_retries == -1 or cur_retries < max_retries ): diff --git a/tests/unit/test_gitlab_http_methods.py b/tests/unit/test_gitlab_http_methods.py index 8481aee..0f0d5d3 100644 --- a/tests/unit/test_gitlab_http_methods.py +++ b/tests/unit/test_gitlab_http_methods.py @@ -102,7 +102,16 @@ def test_http_request_with_retry_on_method_for_transient_failures(gl): @responses.activate -def test_http_request_with_retry_on_method_for_transient_network_failures(gl): +@pytest.mark.parametrize( + "exception", + [ + requests.ConnectionError("Connection aborted."), + requests.exceptions.ChunkedEncodingError("Connection broken."), + ], +) +def test_http_request_with_retry_on_method_for_transient_network_failures( + gl, exception +): call_count = 0 calls_before_success = 3 @@ -117,7 +126,7 @@ def test_http_request_with_retry_on_method_for_transient_network_failures(gl): if call_count >= calls_before_success: return (status_code, headers, body) - raise requests.ConnectionError("Connection aborted.") + raise exception responses.add_callback( method=responses.GET, |