Skip to content

Commit

Permalink
feat!: make Client.poll_interval a private property (#398)
Browse files Browse the repository at this point in the history
Prevent the user to read or edit the poll_interval after the client has
been constructed.
  • Loading branch information
jooola committed Jul 2, 2024
1 parent 9f46adb commit d5f24db
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion hcloud/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(
self._application_version = application_version
self._requests_session = requests.Session()
self._requests_timeout = timeout
self.poll_interval = poll_interval
self._poll_interval = poll_interval

self.datacenters = DatacentersClient(self)
"""DatacentersClient Instance
Expand Down
4 changes: 2 additions & 2 deletions hcloud/actions/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class BoundAction(BoundModelBase, Action):
model = Action

def wait_until_finished(self, max_retries: int = 100) -> None:
"""Wait until the specific action has status="finished" (set Client.poll_interval to specify a delay between checks)
"""Wait until the specific action has status="finished".
:param max_retries: int
Specify how many retries will be performed before an ActionTimeoutException will be raised
Expand All @@ -28,7 +28,7 @@ def wait_until_finished(self, max_retries: int = 100) -> None:
if max_retries > 0:
self.reload()
# pylint: disable=protected-access
time.sleep(self._client._client.poll_interval)
time.sleep(self._client._client._poll_interval)
max_retries = max_retries - 1
else:
raise ActionTimeoutException(action=self)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/actions/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class TestBoundAction:
def bound_running_action(self, mocked_requests):
action_client = ActionsClient(client=mocked_requests)
# Speed up tests that run `wait_until_finished`
action_client._client.poll_interval = 0.1
action_client._client._poll_interval = 0.1

return BoundAction(
client=action_client,
Expand Down

0 comments on commit d5f24db

Please sign in to comment.