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:
committed by
GitHub
parent
084987a3e1
commit
15fa91fb98
@@ -888,6 +888,7 @@ class MinerFactory:
|
|||||||
await writer.drain()
|
await writer.drain()
|
||||||
|
|
||||||
# loop to receive all the data
|
# loop to receive all the data
|
||||||
|
timeouts_remaining = max(1, int(settings.get("factory_get_timeout", 3)))
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
d = await asyncio.wait_for(reader.read(4096), timeout=1)
|
d = await asyncio.wait_for(reader.read(4096), timeout=1)
|
||||||
@@ -895,7 +896,10 @@ class MinerFactory:
|
|||||||
break
|
break
|
||||||
data += d
|
data += d
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
pass
|
timeouts_remaining -= 1
|
||||||
|
if not timeouts_remaining:
|
||||||
|
logger.warning(f"{ip}: Socket ping timeout.")
|
||||||
|
break
|
||||||
except ConnectionResetError:
|
except ConnectionResetError:
|
||||||
return
|
return
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
|
|||||||
Reference in New Issue
Block a user