From a1f7791d5e52c49d255fee4e571db49c20e0c8c1 Mon Sep 17 00:00:00 2001 From: Alexander Borzunov Date: Thu, 3 Aug 2023 02:17:07 +0200 Subject: [PATCH] Fix petals.utils.ping for servers with client-mode DHT (#430) Fix #429. --- src/petals/__init__.py | 2 +- src/petals/utils/ping.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/petals/__init__.py b/src/petals/__init__.py index d2f91bc..c9f8223 100644 --- a/src/petals/__init__.py +++ b/src/petals/__init__.py @@ -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"): diff --git a/src/petals/utils/ping.py b/src/petals/utils/ping.py index 4245bf4..5e3e775 100644 --- a/src/petals/utils/ping.py +++ b/src/petals/utils/ping.py @@ -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