Переглянути джерело

refactor: use P2PHandlerError instread of RemoteError

Denis Mazur 4 роки тому
батько
коміт
6a61895e4b

+ 1 - 4
hivemind/p2p/p2p_daemon.py

@@ -14,6 +14,7 @@ from multiaddr import Multiaddr
 import hivemind.hivemind_cli as cli
 import hivemind.p2p.p2p_daemon_bindings.p2pclient as p2pclient
 from hivemind.p2p.p2p_daemon_bindings.datastructures import PeerID, PeerInfo, StreamInfo
+from hivemind.p2p.p2p_daemon_bindings.control import P2PHandlerError
 from hivemind.proto.p2pd_pb2 import RPCError
 from hivemind.utils.asyncio import aiter
 from hivemind.utils.logging import get_logger
@@ -557,7 +558,3 @@ class P2P:
 
 class P2PInterruptedError(Exception):
     pass
-
-
-class P2PHandlerError(Exception):
-    pass

+ 2 - 2
hivemind/p2p/p2p_daemon_bindings/control.py

@@ -115,7 +115,7 @@ class ControlClient:
                 if call_id in self.pending_calls and resp.callUnaryResponse.HasField("result"):
                     self.pending_calls[call_id].set_result(resp.callUnaryResponse.result)
                 elif call_id in self.pending_calls and resp.callUnaryResponse.HasField("error"):
-                    remote_exc = RemoteException(str(resp.callUnaryResponse.error))
+                    remote_exc = P2PHandlerError(str(resp.callUnaryResponse.error))
                     self.pending_calls[call_id].set_exception(remote_exc)
                 else:
                     logger.debug(f"received unexpected unary call")
@@ -288,7 +288,7 @@ class ControlClient:
         self.handlers[proto] = handler_cb
 
 
-class RemoteException(Exception):
+class P2PHandlerError(Exception):
     """
     Raised if remote handled a request with an exception
     """