From 664d81a8c6b83708aaf61997a04fb23c7d49e478 Mon Sep 17 00:00:00 2001 From: jo Date: Thu, 25 Jul 2024 15:19:05 +0200 Subject: [PATCH] fix: do not sleep before checking for the reloaded action status --- hcloud/actions/client.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/hcloud/actions/client.py b/hcloud/actions/client.py index 85fc007..a3d6b03 100644 --- a/hcloud/actions/client.py +++ b/hcloud/actions/client.py @@ -28,14 +28,18 @@ def wait_until_finished(self, max_retries: int | None = None) -> None: max_retries = self._client._client._poll_max_retries retries = 0 - while self.status == Action.STATUS_RUNNING: + while True: + self.reload() + if self.status != Action.STATUS_RUNNING: + break + + retries += 1 if retries < max_retries: - self.reload() - retries += 1 # pylint: disable=protected-access time.sleep(self._client._client._poll_interval_func(retries)) - else: - raise ActionTimeoutException(action=self) + continue + + raise ActionTimeoutException(action=self) if self.status == Action.STATUS_ERROR: raise ActionFailedException(action=self)