Fix petals.utils.ping for servers with client-mode DHT (#430)

Fix #429.
pull/437/head v2.0.1.post1
Alexander Borzunov 9 months ago committed by GitHub
parent 351e96bc46
commit a1f7791d5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -11,7 +11,7 @@ from petals.models import *
from petals.utils import *
from petals.utils.logging import initialize_logs as _initialize_logs
__version__ = "2.0.1"
__version__ = "2.0.1.post1"
if not os.getenv("PETALS_IGNORE_DEPENDENCY_VERSION"):

@ -24,7 +24,10 @@ async def ping(
start_time = time.perf_counter()
await node.protocol.get_stub(peer_id).rpc_ping(ping_request, timeout=wait_timeout)
return time.perf_counter() - start_time
except Exception:
except Exception as e:
if str(e) == "protocol not supported": # Happens on servers with client-mode DHT (e.g., reachable via relays)
return time.perf_counter() - start_time
logger.debug(f"Failed to ping {peer_id}:", exc_info=True)
return math.inf

Loading…
Cancel
Save