Bläddra i källkod

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

Fix #429.
Alexander Borzunov 2 år sedan
förälder
incheckning
a1f7791d5e
2 ändrade filer med 5 tillägg och 2 borttagningar
  1. 1 1
      src/petals/__init__.py
  2. 4 1
      src/petals/utils/ping.py

+ 1 - 1
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"):

+ 4 - 1
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