Skip to content
Snippets Groups Projects
Commit 0c3f2c01 authored by inso's avatar inso
Browse files

Handle gaierror in hope to resolve bug #273

parent 88eeab68
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ import logging ...@@ -7,6 +7,7 @@ import logging
from aiohttp.errors import ClientError from aiohttp.errors import ClientError
import asyncio import asyncio
import random import random
from socket import gaierror
import jsonschema import jsonschema
from distutils.version import StrictVersion from distutils.version import StrictVersion
...@@ -243,9 +244,7 @@ class BmaAccess(QObject): ...@@ -243,9 +244,7 @@ class BmaAccess(QObject):
if '404' in str(e) or '400' in str(e): if '404' in str(e) or '400' in str(e):
raise raise
tries += 1 tries += 1
except ClientError: except (ClientError, gaierror, asyncio.TimeoutError):
tries += 1
except asyncio.TimeoutError:
tries += 1 tries += 1
except jsonschema.ValidationError as e: except jsonschema.ValidationError as e:
logging.debug(str(e)) logging.debug(str(e))
...@@ -277,9 +276,7 @@ class BmaAccess(QObject): ...@@ -277,9 +276,7 @@ class BmaAccess(QObject):
if '404' in str(e) or '400' in str(e): if '404' in str(e) or '400' in str(e):
raise raise
tries += 1 tries += 1
except ClientError: except (ClientError, gaierror, asyncio.TimeoutError):
tries += 1
except asyncio.TimeoutError:
tries += 1 tries += 1
except jsonschema.ValidationError as e: except jsonschema.ValidationError as e:
logging.debug(str(e)) logging.debug(str(e))
...@@ -315,7 +312,7 @@ class BmaAccess(QObject): ...@@ -315,7 +312,7 @@ class BmaAccess(QObject):
except ValueError as e: except ValueError as e:
if '404' in str(e) or '400' in str(e): if '404' in str(e) or '400' in str(e):
raise raise
except ClientError: except (ClientError, gaierror):
pass pass
except asyncio.TimeoutError: except asyncio.TimeoutError:
pass pass
......
...@@ -15,6 +15,7 @@ from aiohttp.errors import ClientError, DisconnectedError ...@@ -15,6 +15,7 @@ from aiohttp.errors import ClientError, DisconnectedError
import logging import logging
import time import time
import jsonschema import jsonschema
from socket import gaierror
from PyQt5.QtCore import QObject, pyqtSignal from PyQt5.QtCore import QObject, pyqtSignal
...@@ -316,14 +317,8 @@ class Node(QObject): ...@@ -316,14 +317,8 @@ class Node(QObject):
logging.debug("Error in previous block reply : {0}".format(self.pubkey)) logging.debug("Error in previous block reply : {0}".format(self.pubkey))
logging.debug(str(e)) logging.debug(str(e))
self.changed.emit() self.changed.emit()
except ClientError: except (ClientError, gaierror, asyncio.TimeoutError, DisconnectedError) as e:
logging.debug("Client error : {0}".format(self.pubkey)) logging.debug("{0} : {1}".format(str(e), 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))
self.state = Node.OFFLINE self.state = Node.OFFLINE
except jsonschema.ValidationError: except jsonschema.ValidationError:
logging.debug("Validation error : {0}".format(self.pubkey)) logging.debug("Validation error : {0}".format(self.pubkey))
...@@ -342,14 +337,8 @@ class Node(QObject): ...@@ -342,14 +337,8 @@ class Node(QObject):
logging.debug("Error in block reply : {0}".format(self.pubkey)) logging.debug("Error in block reply : {0}".format(self.pubkey))
logging.debug(str(e)) logging.debug(str(e))
self.changed.emit() self.changed.emit()
except ClientError: except (ClientError, gaierror, asyncio.TimeoutError, DisconnectedError) as e:
logging.debug("Client error : {0}".format(self.pubkey)) logging.debug("{0} : {1}".format(str(e), 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))
self.state = Node.OFFLINE self.state = Node.OFFLINE
except jsonschema.ValidationError: except jsonschema.ValidationError:
logging.debug("Validation error : {0}".format(self.pubkey)) logging.debug("Validation error : {0}".format(self.pubkey))
...@@ -383,14 +372,8 @@ class Node(QObject): ...@@ -383,14 +372,8 @@ class Node(QObject):
logging.debug("Error in peering reply : {0}".format(str(e))) logging.debug("Error in peering reply : {0}".format(str(e)))
self.state = Node.OFFLINE self.state = Node.OFFLINE
self.changed.emit() self.changed.emit()
except ClientError: except (ClientError, gaierror, asyncio.TimeoutError, DisconnectedError) as e:
logging.debug("Client error : {0}".format(self.pubkey)) logging.debug("{0} : {1}".format(str(e), 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))
self.state = Node.OFFLINE self.state = Node.OFFLINE
except jsonschema.ValidationError: except jsonschema.ValidationError:
logging.debug("Validation error : {0}".format(self.pubkey)) logging.debug("Validation error : {0}".format(self.pubkey))
...@@ -417,14 +400,8 @@ class Node(QObject): ...@@ -417,14 +400,8 @@ class Node(QObject):
logging.debug("Error in summary : {0}".format(e)) logging.debug("Error in summary : {0}".format(e))
self.state = Node.OFFLINE self.state = Node.OFFLINE
self.changed.emit() self.changed.emit()
except ClientError: except (ClientError, gaierror, asyncio.TimeoutError, DisconnectedError) as e:
logging.debug("Client error : {0}".format(self.pubkey)) logging.debug("{0} : {1}".format(str(e), 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))
self.state = Node.OFFLINE self.state = Node.OFFLINE
except jsonschema.ValidationError: except jsonschema.ValidationError:
logging.debug("Validation error : {0}".format(self.pubkey)) logging.debug("Validation error : {0}".format(self.pubkey))
...@@ -459,14 +436,8 @@ class Node(QObject): ...@@ -459,14 +436,8 @@ class Node(QObject):
logging.debug("error in uid reply") logging.debug("error in uid reply")
self.state = Node.OFFLINE self.state = Node.OFFLINE
self.identity_changed.emit() self.identity_changed.emit()
except ClientError: except (ClientError, gaierror, asyncio.TimeoutError, DisconnectedError) as e:
logging.debug("Client error : {0}".format(self.pubkey)) logging.debug("{0} : {1}".format(str(e), 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))
self.state = Node.OFFLINE self.state = Node.OFFLINE
except jsonschema.ValidationError: except jsonschema.ValidationError:
logging.debug("Validation error : {0}".format(self.pubkey)) logging.debug("Validation error : {0}".format(self.pubkey))
...@@ -500,14 +471,8 @@ class Node(QObject): ...@@ -500,14 +471,8 @@ class Node(QObject):
logging.debug("Error in leaf reply") logging.debug("Error in leaf reply")
self.state = Node.OFFLINE self.state = Node.OFFLINE
self.changed.emit() self.changed.emit()
except ClientError: except (ClientError, gaierror, asyncio.TimeoutError, DisconnectedError) as e:
logging.debug("Client error : {0}".format(self.pubkey)) logging.debug("{0} : {1}".format(str(e), 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))
self.state = Node.OFFLINE self.state = Node.OFFLINE
except jsonschema.ValidationError: except jsonschema.ValidationError:
logging.debug("Validation error : {0}".format(self.pubkey)) logging.debug("Validation error : {0}".format(self.pubkey))
...@@ -518,14 +483,8 @@ class Node(QObject): ...@@ -518,14 +483,8 @@ class Node(QObject):
logging.debug("Error in peers reply") logging.debug("Error in peers reply")
self.state = Node.OFFLINE self.state = Node.OFFLINE
self.changed.emit() self.changed.emit()
except ClientError: except (ClientError, gaierror, asyncio.TimeoutError, DisconnectedError) as e:
logging.debug("Client error : {0}".format(self.pubkey)) logging.debug("{0} : {1}".format(str(e), 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))
self.state = Node.OFFLINE self.state = Node.OFFLINE
except jsonschema.ValidationError: except jsonschema.ValidationError:
logging.debug("Validation error : {0}".format(self.pubkey)) logging.debug("Validation error : {0}".format(self.pubkey))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment