diff --git a/PyCrypCli/client.py b/PyCrypCli/client.py index dd3111f..f3cc6fc 100644 --- a/PyCrypCli/client.py +++ b/PyCrypCli/client.py @@ -104,7 +104,7 @@ def request(self, data: dict[str, Any], no_response: bool = False) -> dict[str, self.waiting_for_response = False return response - def ms(self, ms: str, endpoint: list[str], **data: Any) -> dict[str, Any]: + def ms(self, ms: str, endpoint: list[str], *, retry: int = 0, **data: Any) -> dict[str, Any]: if not self.logged_in: raise LoggedOutError @@ -128,6 +128,9 @@ def ms(self, ms: str, endpoint: list[str], **data: Any) -> dict[str, Any]: raise exception(error, list(match.groups())) raise InvalidServerResponseError(response) + if not response_data and retry: + return self.ms(ms, endpoint, retry=retry - 1, **data) + return response_data def register(self, username: str, password: str) -> TokenResponse: diff --git a/PyCrypCli/models/service/miner.py b/PyCrypCli/models/service/miner.py index f3a7972..095faf1 100644 --- a/PyCrypCli/models/service/miner.py +++ b/PyCrypCli/models/service/miner.py @@ -25,7 +25,7 @@ def get_miner(client: Client, device_uuid: str) -> Miner: def get_miners(client: Client, wallet_uuid: str) -> list[Miner]: return [ Miner.parse(client, {**miner["service"], **miner["miner"]}) - for miner in client.ms("service", ["miner", "list"], wallet_uuid=wallet_uuid)["miners"] + for miner in client.ms("service", ["miner", "list"], retry=5, wallet_uuid=wallet_uuid)["miners"] ] @staticmethod