Skip to content

Add ChunkedEncodingError to list of retryable exceptions #1974

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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