Skip to content

Commit

Permalink
fix: add ChunkedEncodingError to list of retryable exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Clayton Walker committed Apr 13, 2022
1 parent 5370979 commit 7beb20f
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
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

0 comments on commit 7beb20f

Please sign in to comment.