electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 6ec1578a90916436b3bfabe90cafd9bfc804a332
parent fecef91ee02352016bcf6990821c2a42e84d2a82
Author: SomberNight <somber.night@protonmail.com>
Date:   Tue, 21 May 2019 18:43:16 +0200

follow-up prev

Diffstat:
Melectrum/interface.py | 18+++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/electrum/interface.py b/electrum/interface.py @@ -167,6 +167,15 @@ class RequestTimedOut(GracefulDisconnect): class ErrorParsingSSLCert(Exception): pass class ErrorGettingSSLCertFromServer(Exception): pass +class ConnectError(Exception): pass + + +class _Connector(aiorpcx.Connector): + async def create_connection(self): + try: + return await super().create_connection() + except OSError as e: + raise ConnectError(e) def deserialize_server(server_str: str) -> Tuple[str, str, str]: @@ -333,8 +342,7 @@ class Interface(Logger): return try: await self.open_session(ssl_context) - except (asyncio.CancelledError, ConnectionError, socket.gaierror, aiorpcx.socks.SOCKSError) as e: - # note: catching OSError would be too broad here... don't want to catch file system exceptions + except (asyncio.CancelledError, ConnectError, aiorpcx.socks.SOCKSError) as e: self.logger.info(f'disconnecting due to: {repr(e)}') return @@ -419,9 +427,9 @@ class Interface(Logger): return self.network.default_server == self.server async def open_session(self, sslc, exit_early=False): - async with aiorpcx.Connector(NotificationSession, - host=self.host, port=self.port, - ssl=sslc, proxy=self.proxy) as session: + async with _Connector(NotificationSession, + host=self.host, port=self.port, + ssl=sslc, proxy=self.proxy) as session: self.session = session # type: NotificationSession self.session.interface = self self.session.set_default_timeout(self.network.get_network_timeout_seconds(NetworkTimeout.Generic))