electrum

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

commit 1419a5c60d7dc3b0f45846c3d5873b4b32d147b1
parent 6f7a065081dd28b552ae43238a95685edc6aa424
Author: SomberNight <somber.night@protonmail.com>
Date:   Wed, 12 Sep 2018 18:43:50 +0200

interface: change how GracefulDisconnect is handled

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

diff --git a/electrum/interface.py b/electrum/interface.py @@ -96,8 +96,7 @@ class NotificationSession(ClientSession): return str(method) + repr(params) -# FIXME this is often raised inside a TaskGroup, but then it's not silent :( -class GracefulDisconnect(AIOSafeSilentException): pass +class GracefulDisconnect(Exception): pass class ErrorParsingSSLCert(Exception): pass @@ -226,7 +225,17 @@ class Interface(PrintError): sslc.check_hostname = 0 return sslc + def handle_graceful_disconnect(func): + async def wrapper_func(self, *args, **kwargs): + try: + return await func(self, *args, **kwargs) + except GracefulDisconnect as e: + self.print_error("disconnecting gracefully. {}".format(e)) + self.exception = e + return wrapper_func + @aiosafe + @handle_graceful_disconnect async def run(self): try: ssl_context = await self._get_ssl_context()