Skip to content

Commit 8244282

Browse files
author
Clayton Walker
committed
Add ChunkedEncodingError to list of retryable exceptions
1 parent 5370979 commit 8244282

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
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

+31
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,37 @@ def request_callback(request):
129129
assert len(responses.calls) == calls_before_success
130130

131131

132+
@responses.activate
133+
def test_http_request_with_retry_on_method_for_transient_network_failures_chunked(gl):
134+
call_count = 0
135+
calls_before_success = 3
136+
137+
url = "http://localhost/api/v4/projects"
138+
139+
def request_callback(request):
140+
nonlocal call_count
141+
call_count += 1
142+
status_code = 200
143+
headers = {}
144+
body = "[]"
145+
146+
if call_count >= calls_before_success:
147+
return (status_code, headers, body)
148+
raise requests.exceptions.ChunkedEncodingError("todo")
149+
150+
responses.add_callback(
151+
method=responses.GET,
152+
url=url,
153+
callback=request_callback,
154+
content_type="application/json",
155+
)
156+
157+
http_r = gl.http_request("get", "/projects", retry_transient_errors=True)
158+
159+
assert http_r.status_code == 200
160+
assert len(responses.calls) == calls_before_success
161+
162+
132163
@responses.activate
133164
def test_http_request_with_retry_on_class_for_transient_failures(gl_retry):
134165
call_count = 0

0 commit comments

Comments
 (0)