Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gitlab/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,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
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,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 @@ -114,7 +123,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