Skip to content

Commit d5f24db

Browse files
authored
feat!: make Client.poll_interval a private property (#398)
Prevent the user to read or edit the poll_interval after the client has been constructed.
1 parent 9f46adb commit d5f24db

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

hcloud/_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def __init__(
5757
self._application_version = application_version
5858
self._requests_session = requests.Session()
5959
self._requests_timeout = timeout
60-
self.poll_interval = poll_interval
60+
self._poll_interval = poll_interval
6161

6262
self.datacenters = DatacentersClient(self)
6363
"""DatacentersClient Instance

hcloud/actions/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class BoundAction(BoundModelBase, Action):
1717
model = Action
1818

1919
def wait_until_finished(self, max_retries: int = 100) -> None:
20-
"""Wait until the specific action has status="finished" (set Client.poll_interval to specify a delay between checks)
20+
"""Wait until the specific action has status="finished".
2121
2222
:param max_retries: int
2323
Specify how many retries will be performed before an ActionTimeoutException will be raised
@@ -28,7 +28,7 @@ def wait_until_finished(self, max_retries: int = 100) -> None:
2828
if max_retries > 0:
2929
self.reload()
3030
# pylint: disable=protected-access
31-
time.sleep(self._client._client.poll_interval)
31+
time.sleep(self._client._client._poll_interval)
3232
max_retries = max_retries - 1
3333
else:
3434
raise ActionTimeoutException(action=self)

tests/unit/actions/test_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class TestBoundAction:
1919
def bound_running_action(self, mocked_requests):
2020
action_client = ActionsClient(client=mocked_requests)
2121
# Speed up tests that run `wait_until_finished`
22-
action_client._client.poll_interval = 0.1
22+
action_client._client._poll_interval = 0.1
2323

2424
return BoundAction(
2525
client=action_client,

0 commit comments

Comments
 (0)