Skip to content

Commit 7183898

Browse files
author
Clayton Walker
committed
fix: add ChunkedEncodingError to list of retryable exceptions
1 parent 5370979 commit 7183898

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

gitlab/client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ def http_request(
694694
stream=streamed,
695695
**opts,
696696
)
697-
except requests.ConnectionError:
697+
except (requests.ConnectionError, requests.exceptions.ChunkedEncodingError):
698698
if retry_transient_errors and (
699699
max_retries == -1 or cur_retries < max_retries
700700
):

tests/unit/test_gitlab_http_methods.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,13 @@ def request_callback(request):
9999

100100

101101
@responses.activate
102-
def test_http_request_with_retry_on_method_for_transient_network_failures(gl):
102+
@pytest.mark.parametrize(
103+
"exception", [
104+
requests.ConnectionError("Connection aborted."),
105+
requests.exceptions.ChunkedEncodingError("Connection broken.")
106+
]
107+
)
108+
def test_http_request_with_retry_on_method_for_transient_network_failures(gl, exception):
103109
call_count = 0
104110
calls_before_success = 3
105111

@@ -114,7 +120,7 @@ def request_callback(request):
114120

115121
if call_count >= calls_before_success:
116122
return (status_code, headers, body)
117-
raise requests.ConnectionError("Connection aborted.")
123+
raise exception
118124

119125
responses.add_callback(
120126
method=responses.GET,

0 commit comments

Comments
 (0)