Skip to content
This repository has been archived by the owner on Apr 16, 2023. It is now read-only.

Commit

Permalink
Added retry parameter to ms function
Browse files Browse the repository at this point in the history
  • Loading branch information
Defelo committed Mar 8, 2022
1 parent f0a8535 commit c2c5b28
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion PyCrypCli/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion PyCrypCli/models/service/miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c2c5b28

Please sign in to comment.