bug: don’t timeout forever on _socket_ping (#288)

* Don't timeout forever on _socket_ping

* Use factory_get_timeout to configure number of allowed retries

* Add warning log
This commit is contained in:
Erik Olof Gunnar Andersson
2025-01-30 15:05:29 +01:00
committed by GitHub
parent 084987a3e1
commit 15fa91fb98

View File

@@ -888,6 +888,7 @@ class MinerFactory:
await writer.drain()
# loop to receive all the data
timeouts_remaining = max(1, int(settings.get("factory_get_timeout", 3)))
while True:
try:
d = await asyncio.wait_for(reader.read(4096), timeout=1)
@@ -895,7 +896,10 @@ class MinerFactory:
break
data += d
except asyncio.TimeoutError:
pass
timeouts_remaining -= 1
if not timeouts_remaining:
logger.warning(f"{ip}: Socket ping timeout.")
break
except ConnectionResetError:
return
except asyncio.CancelledError: