Skip to content

Commit

Permalink
Merge pull request #1974 from Sineaggi/add-chunked-to-list-of-retryab…
Browse files Browse the repository at this point in the history
…le-exceptions

Add ChunkedEncodingError to list of retryable exceptions
  • Loading branch information
nejch committed Apr 14, 2022
2 parents 69ace2d + 7beb20f commit 07a16af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gitlab/client.py
Expand Up @@ -701,7 +701,7 @@ def http_request(
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
):
Expand Down
13 changes: 11 additions & 2 deletions tests/unit/test_gitlab_http_methods.py
Expand Up @@ -102,7 +102,16 @@ def request_callback(request):


@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

Expand All @@ -117,7 +126,7 @@ def request_callback(request):

if call_count >= calls_before_success:
return (status_code, headers, body)
raise requests.ConnectionError("Connection aborted.")
raise exception

responses.add_callback(
method=responses.GET,
Expand Down

0 comments on commit 07a16af

Please sign in to comment.