Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: make Client.poll_interval a private property #398

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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