Retry and Timeout Changes for espminer (#340)

* Retry and Timeout Fixes for espminer

* Build check fix
This commit is contained in:
Ryan Heideman
2025-05-01 14:07:58 -07:00
committed by GitHub
parent b8ae238d23
commit 40ebc2773f

View File

@@ -20,10 +20,9 @@ class ESPMinerWebAPI(BaseWebAPI):
**parameters: Any, **parameters: Any,
) -> dict: ) -> dict:
url = f"http://{self.ip}:{self.port}/api/{command}" url = f"http://{self.ip}:{self.port}/api/{command}"
async with httpx.AsyncClient(transport=settings.transport()) as client:
for _ in range(settings.get("get_data_retries", 1)):
try: try:
async with httpx.AsyncClient(
transport=settings.transport(),
) as client:
if parameters.get("post", False): if parameters.get("post", False):
parameters.pop("post") parameters.pop("post")
data = await client.post( data = await client.post(
@@ -39,7 +38,10 @@ class ESPMinerWebAPI(BaseWebAPI):
json=parameters, json=parameters,
) )
else: else:
data = await client.get(url) data = await client.get(
url,
timeout=settings.get("api_function_timeout", 5),
)
except httpx.HTTPError: except httpx.HTTPError:
pass pass
else: else: