make ePIC api calls more reliable
This commit is contained in:
@@ -939,11 +939,14 @@ class MinerFactory:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
async def get_miner_model_epic(self, ip: str) -> str | None:
|
async def get_miner_model_epic(self, ip: str) -> str | None:
|
||||||
|
for retry_cnt in range(settings.get("get_data_retries", 1)):
|
||||||
sock_json_data = await self.send_web_command(ip, ":4028/capabilities")
|
sock_json_data = await self.send_web_command(ip, ":4028/capabilities")
|
||||||
try:
|
try:
|
||||||
miner_model = sock_json_data["Model"]
|
miner_model = sock_json_data["Model"]
|
||||||
return miner_model
|
return miner_model
|
||||||
except (TypeError, LookupError):
|
except (TypeError, LookupError):
|
||||||
|
if retry_cnt < settings.get("get_data_retries", 1) - 1:
|
||||||
|
continue
|
||||||
pass
|
pass
|
||||||
|
|
||||||
async def get_miner_model_hiveon(self, ip: str) -> str | None:
|
async def get_miner_model_hiveon(self, ip: str) -> str | None:
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ class ePICWebAPI(BaseWebAPI):
|
|||||||
post = privileged or not parameters == {}
|
post = privileged or not parameters == {}
|
||||||
|
|
||||||
async with httpx.AsyncClient(transport=settings.transport()) as client:
|
async with httpx.AsyncClient(transport=settings.transport()) as client:
|
||||||
|
for retry_cnt in range(settings.get("get_data_retries", 1)):
|
||||||
try:
|
try:
|
||||||
if post:
|
if post:
|
||||||
response = await client.post(
|
response = await client.post(
|
||||||
@@ -69,6 +70,8 @@ class ePICWebAPI(BaseWebAPI):
|
|||||||
if json_data:
|
if json_data:
|
||||||
# The API can return a fail status if the miner cannot return the requested data. Catch this and pass
|
# The API can return a fail status if the miner cannot return the requested data. Catch this and pass
|
||||||
if not json_data.get("result", True) and not post:
|
if not json_data.get("result", True) and not post:
|
||||||
|
if retry_cnt < settings.get("get_data_retries", 1) - 1:
|
||||||
|
continue
|
||||||
if not ignore_errors:
|
if not ignore_errors:
|
||||||
raise APIError(json_data["error"])
|
raise APIError(json_data["error"])
|
||||||
return json_data
|
return json_data
|
||||||
|
|||||||
Reference in New Issue
Block a user