Skip to content

Commit 07a16af

Browse files
authored
Merge pull request python-gitlab#1974 from Sineaggi/add-chunked-to-list-of-retryable-exceptions
Add ChunkedEncodingError to list of retryable exceptions
2 parents 69ace2d + 7beb20f commit 07a16af

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

gitlab/client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ def http_request(
701701
stream=streamed,
702702
**opts,
703703
)
704-
except requests.ConnectionError:
704+
except (requests.ConnectionError, requests.exceptions.ChunkedEncodingError):
705705
if retry_transient_errors and (
706706
max_retries == -1 or cur_retries < max_retries
707707
):

tests/unit/test_gitlab_http_methods.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,16 @@ def request_callback(request):
102102

103103

104104
@responses.activate
105-
def test_http_request_with_retry_on_method_for_transient_network_failures(gl):
105+
@pytest.mark.parametrize(
106+
"exception",
107+
[
108+
requests.ConnectionError("Connection aborted."),
109+
requests.exceptions.ChunkedEncodingError("Connection broken."),
110+
],
111+
)
112+
def test_http_request_with_retry_on_method_for_transient_network_failures(
113+
gl, exception
114+
):
106115
call_count = 0
107116
calls_before_success = 3
108117

@@ -117,7 +126,7 @@ def request_callback(request):
117126

118127
if call_count >= calls_before_success:
119128
return (status_code, headers, body)
120-
raise requests.ConnectionError("Connection aborted.")
129+
raise exception
121130

122131
responses.add_callback(
123132
method=responses.GET,

0 commit comments

Comments
 (0)