From 2942724700438797f124b0cb939956fdb056aef7 Mon Sep 17 00:00:00 2001 From: Alexander Stepchenko Date: Mon, 29 Apr 2024 04:03:52 +0300 Subject: [PATCH] feat: make sleep time a function paramater instead of hard-coding it --- main.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index 509a3ae..54cce29 100644 --- a/main.py +++ b/main.py @@ -25,11 +25,11 @@ PROXMOX_USER_FULL: str | None = os.environ.get('PROXMOX_USER_FULL') PROXMOX_PASSWORD: str | None = os.environ.get('PROXMOX_PASSWORD') -def wait_status(funcs: List[Callable], status: str): +def wait_status(funcs: list[Callable[[], dict[str, str]]], status: str, sleep_time: float = 60) -> None: statuses = [False] * len(funcs) while not all(statuses): logger.debug(statuses) - sleep(5) + sleep(sleep_time) for i in range(len(funcs)): statuses[i] = funcs[i]()['status'] == status @@ -108,8 +108,9 @@ def main() -> None: proxmox.nodes(node).tasks(upid_master).status.get, proxmox.nodes(node).tasks(upid_worker1).status.get, proxmox.nodes(node).tasks(upid_worker2).status.get, - ], - 'stopped' + ], # pyright: ignore + 'stopped', + sleep_time=60, ) logger.info('Cloning completed!') @@ -123,8 +124,9 @@ def main() -> None: proxmox.nodes(node).qemu(vm_ids['master']).status.current.get, proxmox.nodes(node).qemu(vm_ids['worker1']).status.current.get, proxmox.nodes(node).qemu(vm_ids['worker2']).status.current.get, - ], - 'running' + ], # pyright: ignore + 'running', + sleep_time=10, ) sleep(40)