Skip to content
Open
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
3 changes: 2 additions & 1 deletion docs/api-usage-advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ python-gitlab can automatically retry in such case, when
``retry_transient_errors`` argument is set to ``True``. When enabled,
HTTP error codes 500 (Internal Server Error), 502 (502 Bad Gateway),
503 (Service Unavailable), 504 (Gateway Timeout), and Cloudflare
errors (520-530) are retried.
errors (520-530) are retried. `requests.exceptions.Timeout` are also
handled.

Additionally, HTTP error code 409 (Conflict) is retried if the reason
is a
Expand Down
10 changes: 7 additions & 3 deletions gitlab/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Gitlab:
order_by: Set order_by globally
user_agent: A custom user agent to use for making HTTP requests.
retry_transient_errors: Whether to retry after 500, 502, 503, 504
or 52x responses. Defaults to False.
or 52x responses, or after a request timeout. Defaults to False.
keep_base_url: keep user-provided base URL for pagination if it
differs from response headers

Expand Down Expand Up @@ -665,7 +665,7 @@ def http_request(
obey_rate_limit: Whether to obey 429 Too Many Request
responses. Defaults to True.
retry_transient_errors: Whether to retry after 500, 502, 503, 504
or 52x responses. Defaults to False.
or 52x responses, or after a request timeout. Defaults to False.
max_retries: Max retries after 429 or transient errors,
set to -1 to retry forever. Defaults to 10.
extra_headers: Add and override HTTP headers for the request.
Expand Down Expand Up @@ -737,7 +737,11 @@ def http_request(
stream=streamed,
**opts,
)
except (requests.ConnectionError, requests.exceptions.ChunkedEncodingError):
except (
requests.ConnectionError,
requests.exceptions.ChunkedEncodingError,
requests.exceptions.Timeout,
):
if retry.handle_retry():
continue
raise
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_gitlab_http_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def test_http_request_extra_headers(gl):
[
requests.ConnectionError("Connection aborted."),
requests.exceptions.ChunkedEncodingError("Connection broken."),
requests.exceptions.Timeout("Request timed out."),
],
)
def test_http_request_with_retry_on_method_for_transient_network_failures(
Expand Down
Loading