diff options
author | Petr Špaček <pspacek@isc.org> | 2022-10-18 14:13:20 +0200 |
---|---|---|
committer | Nejc Habjan <hab.nejc@gmail.com> | 2022-12-19 22:58:03 +0100 |
commit | dced76a9900c626c9f0b90b85a5e371101a24fb4 (patch) | |
tree | 9af498aa58c5125daddc2d905c2e8963c0b2e760 | |
parent | 043de2d265e0e5114d1cd901f82869c003413d9b (diff) | |
download | gitlab-dced76a9900c626c9f0b90b85a5e371101a24fb4.tar.gz |
feat(client): automatically retry on HTTP 409 Resource lock
Fixes: #2325
-rw-r--r-- | docs/api-usage-advanced.rst | 8 | ||||
-rw-r--r-- | gitlab/client.py | 5 |
2 files changed, 9 insertions, 4 deletions
diff --git a/docs/api-usage-advanced.rst b/docs/api-usage-advanced.rst index 2b069b8..256ae2d 100644 --- a/docs/api-usage-advanced.rst +++ b/docs/api-usage-advanced.rst @@ -123,9 +123,11 @@ GitLab server can sometimes return a transient HTTP error. 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), and 504 (Gateway Timeout) are retried. It will retry until reaching -the ``max_retries`` value. By default, ``retry_transient_errors`` is set to ``False`` and an exception -is raised for these errors. +503 (Service Unavailable), and 504 (Gateway Timeout) are retried. +Additionally the HTTP error code 409 (Conflict) is retried if the text message +mentions "Resource lock". It will retry until reaching the ``max_retries`` +value. By default, ``retry_transient_errors`` is set to ``False`` and an +exception is raised for these errors. .. code-block:: python diff --git a/gitlab/client.py b/gitlab/client.py index f558291..f9462ba 100644 --- a/gitlab/client.py +++ b/gitlab/client.py @@ -752,7 +752,10 @@ class Gitlab: return result.response if (429 == result.status_code and obey_rate_limit) or ( - result.status_code in gitlab.const.RETRYABLE_TRANSIENT_ERROR_CODES + ( + result.status_code in gitlab.const.RETRYABLE_TRANSIENT_ERROR_CODES + or (result.status_code == 409 and "Resource lock" in result.reason) + ) and retry_transient_errors ): # Response headers documentation: |