diff --git a/src/cutecoin/core/net/api/bma/access.py b/src/cutecoin/core/net/api/bma/access.py index 9c4210cff5523dec87e05a2368a87a97812a227d..671a9d4d47e1e8f85db2b09c84421b24ffef051a 100644 --- a/src/cutecoin/core/net/api/bma/access.py +++ b/src/cutecoin/core/net/api/bma/access.py @@ -7,6 +7,7 @@ import logging from aiohttp.errors import ClientError import asyncio import random +from socket import gaierror import jsonschema from distutils.version import StrictVersion @@ -243,9 +244,7 @@ class BmaAccess(QObject): if '404' in str(e) or '400' in str(e): raise tries += 1 - except ClientError: - tries += 1 - except asyncio.TimeoutError: + except (ClientError, gaierror, asyncio.TimeoutError): tries += 1 except jsonschema.ValidationError as e: logging.debug(str(e)) @@ -277,9 +276,7 @@ class BmaAccess(QObject): if '404' in str(e) or '400' in str(e): raise tries += 1 - except ClientError: - tries += 1 - except asyncio.TimeoutError: + except (ClientError, gaierror, asyncio.TimeoutError): tries += 1 except jsonschema.ValidationError as e: logging.debug(str(e)) @@ -315,7 +312,7 @@ class BmaAccess(QObject): except ValueError as e: if '404' in str(e) or '400' in str(e): raise - except ClientError: + except (ClientError, gaierror): pass except asyncio.TimeoutError: pass diff --git a/src/cutecoin/core/net/node.py b/src/cutecoin/core/net/node.py index 8340806aac8bae6288723b9d5990fe58c6759264..a23ce1e91290377b2d7eadcf150ac16eec9b10f3 100644 --- a/src/cutecoin/core/net/node.py +++ b/src/cutecoin/core/net/node.py @@ -15,6 +15,7 @@ from aiohttp.errors import ClientError, DisconnectedError import logging import time import jsonschema +from socket import gaierror from PyQt5.QtCore import QObject, pyqtSignal @@ -316,14 +317,8 @@ class Node(QObject): logging.debug("Error in previous block reply : {0}".format(self.pubkey)) logging.debug(str(e)) self.changed.emit() - except ClientError: - logging.debug("Client error : {0}".format(self.pubkey)) - self.state = Node.OFFLINE - except DisconnectedError: - logging.debug("Disconnected error : {0}".format(self.pubkey)) - self.state = Node.OFFLINE - except asyncio.TimeoutError: - logging.debug("Timeout error : {0}".format(self.pubkey)) + except (ClientError, gaierror, asyncio.TimeoutError, DisconnectedError) as e: + logging.debug("{0} : {1}".format(str(e), self.pubkey)) self.state = Node.OFFLINE except jsonschema.ValidationError: logging.debug("Validation error : {0}".format(self.pubkey)) @@ -342,14 +337,8 @@ class Node(QObject): logging.debug("Error in block reply : {0}".format(self.pubkey)) logging.debug(str(e)) self.changed.emit() - except ClientError: - logging.debug("Client error : {0}".format(self.pubkey)) - self.state = Node.OFFLINE - except DisconnectedError: - logging.debug("Disconnected error : {0}".format(self.pubkey)) - self.state = Node.OFFLINE - except asyncio.TimeoutError: - logging.debug("Timeout error : {0}".format(self.pubkey)) + except (ClientError, gaierror, asyncio.TimeoutError, DisconnectedError) as e: + logging.debug("{0} : {1}".format(str(e), self.pubkey)) self.state = Node.OFFLINE except jsonschema.ValidationError: logging.debug("Validation error : {0}".format(self.pubkey)) @@ -383,14 +372,8 @@ class Node(QObject): logging.debug("Error in peering reply : {0}".format(str(e))) self.state = Node.OFFLINE self.changed.emit() - except ClientError: - logging.debug("Client error : {0}".format(self.pubkey)) - self.state = Node.OFFLINE - except asyncio.TimeoutError: - logging.debug("Timeout error : {0}".format(self.pubkey)) - self.state = Node.OFFLINE - except DisconnectedError: - logging.debug("Disconnected error : {0}".format(self.pubkey)) + except (ClientError, gaierror, asyncio.TimeoutError, DisconnectedError) as e: + logging.debug("{0} : {1}".format(str(e), self.pubkey)) self.state = Node.OFFLINE except jsonschema.ValidationError: logging.debug("Validation error : {0}".format(self.pubkey)) @@ -417,14 +400,8 @@ class Node(QObject): logging.debug("Error in summary : {0}".format(e)) self.state = Node.OFFLINE self.changed.emit() - except ClientError: - logging.debug("Client error : {0}".format(self.pubkey)) - self.state = Node.OFFLINE - except asyncio.TimeoutError: - logging.debug("Timeout error : {0}".format(self.pubkey)) - self.state = Node.OFFLINE - except DisconnectedError: - logging.debug("Disconnected error : {0}".format(self.pubkey)) + except (ClientError, gaierror, asyncio.TimeoutError, DisconnectedError) as e: + logging.debug("{0} : {1}".format(str(e), self.pubkey)) self.state = Node.OFFLINE except jsonschema.ValidationError: logging.debug("Validation error : {0}".format(self.pubkey)) @@ -459,14 +436,8 @@ class Node(QObject): logging.debug("error in uid reply") self.state = Node.OFFLINE self.identity_changed.emit() - except ClientError: - logging.debug("Client error : {0}".format(self.pubkey)) - self.state = Node.OFFLINE - except asyncio.TimeoutError: - logging.debug("Timeout error : {0}".format(self.pubkey)) - self.state = Node.OFFLINE - except DisconnectedError: - logging.debug("Disconnected error : {0}".format(self.pubkey)) + except (ClientError, gaierror, asyncio.TimeoutError, DisconnectedError) as e: + logging.debug("{0} : {1}".format(str(e), self.pubkey)) self.state = Node.OFFLINE except jsonschema.ValidationError: logging.debug("Validation error : {0}".format(self.pubkey)) @@ -500,14 +471,8 @@ class Node(QObject): logging.debug("Error in leaf reply") self.state = Node.OFFLINE self.changed.emit() - except ClientError: - logging.debug("Client error : {0}".format(self.pubkey)) - self.state = Node.OFFLINE - except asyncio.TimeoutError: - logging.debug("Timeout error : {0}".format(self.pubkey)) - self.state = Node.OFFLINE - except DisconnectedError: - logging.debug("Disconnected error : {0}".format(self.pubkey)) + except (ClientError, gaierror, asyncio.TimeoutError, DisconnectedError) as e: + logging.debug("{0} : {1}".format(str(e), self.pubkey)) self.state = Node.OFFLINE except jsonschema.ValidationError: logging.debug("Validation error : {0}".format(self.pubkey)) @@ -518,14 +483,8 @@ class Node(QObject): logging.debug("Error in peers reply") self.state = Node.OFFLINE self.changed.emit() - except ClientError: - logging.debug("Client error : {0}".format(self.pubkey)) - self.state = Node.OFFLINE - except asyncio.TimeoutError: - logging.debug("Timeout error : {0}".format(self.pubkey)) - self.state = Node.OFFLINE - except DisconnectedError: - logging.debug("Disconnected error : {0}".format(self.pubkey)) + except (ClientError, gaierror, asyncio.TimeoutError, DisconnectedError) as e: + logging.debug("{0} : {1}".format(str(e), self.pubkey)) self.state = Node.OFFLINE except jsonschema.ValidationError: logging.debug("Validation error : {0}".format(self.pubkey))