Skip to content

Commit 2ff0060

Browse files
committed
feat: retry requests on api bad_gateway error
1 parent 78301e0 commit 2ff0060

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

hcloud/_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ class Client:
129129
130130
- ``conflict``
131131
- ``rate_limit_exceeded``
132+
- ``bad_gateway``
132133
- ``timeout``
133134
134135
Changes to the retry policy might occur between releases, and will not be considered
@@ -420,6 +421,7 @@ def _retry_policy(self, exception: APIException) -> bool:
420421
return exception.code in (
421422
"rate_limit_exceeded",
422423
"conflict",
424+
"bad_gateway",
423425
"timeout",
424426
)
425427

tests/unit/test_client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ def test_init(self, client: ClientBase):
106106
APIException(code="conflict", message="Error", details=None),
107107
True,
108108
),
109+
(
110+
APIException(code="bad_gateway", message="Error", details=None),
111+
True,
112+
),
109113
(
110114
APIException(code=409, message="Conflict", details=None),
111115
False,

0 commit comments

Comments
 (0)