Skip to content

Commit

Permalink
feat!: make Client.request tries a private argument (#399)
Browse files Browse the repository at this point in the history
The argument was already marked as internal, this makes sure we follow
the private name convention.
  • Loading branch information
jooola committed Jul 2, 2024
1 parent d5f24db commit 428ea7e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions hcloud/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,14 @@ def request( # type: ignore[no-untyped-def]
self,
method: str,
url: str,
tries: int = 1,
*,
_tries: int = 1,
**kwargs,
) -> dict:
"""Perform a request to the Hetzner Cloud API, wrapper around requests.request
:param method: HTTP Method to perform the Request
:param url: URL of the Endpoint
:param tries: Tries of the request (used internally, should not be set by the user)
:param timeout: Requests timeout in seconds
:return: Response
"""
Expand All @@ -220,10 +220,10 @@ def request( # type: ignore[no-untyped-def]
if not response.ok:
if content:
assert isinstance(content, dict)
if content["error"]["code"] == "rate_limit_exceeded" and tries < 5:
time.sleep(tries * self._retry_wait_time)
tries = tries + 1
return self.request(method, url, tries, **kwargs)
if content["error"]["code"] == "rate_limit_exceeded" and _tries < 5:
time.sleep(_tries * self._retry_wait_time)
_tries = _tries + 1
return self.request(method, url, _tries=_tries, **kwargs)

self._raise_exception_from_content(content)
else:
Expand Down

0 comments on commit 428ea7e

Please sign in to comment.