diff --git a/requirements.txt b/requirements.txt index 29c8678a1dc957ce10be5878630e0ac72359b8da..75ee25c58bd5cd81d6ca2abee42b9aec27ecc9bd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,4 @@ git+https://github.com/hynek/attrs.git@master git+https://github.com/duniter/duniter-python-api.git@dev pytest pytest-asyncio -git+https://github.com/Insoleet/mirage@master \ No newline at end of file +git+https://github.com/Insoleet/mirage@master diff --git a/src/sakia/data/connectors/bma.py b/src/sakia/data/connectors/bma.py index 0a31f12856b4f374715fe9ac7804f9f82020becb..a0f63c8aa1b6e243852a62faa6c7c38ec820decf 100644 --- a/src/sakia/data/connectors/bma.py +++ b/src/sakia/data/connectors/bma.py @@ -52,20 +52,19 @@ class BmaConnector: :return: The returned data """ endpoints = self.filter_endpoints(request, self._nodes_processor.synced_nodes(currency)) - if len(endpoints) > 0: - tries = 0 - while tries < 3: - endpoint = random.choice(endpoints) - endpoints.remove(endpoint) - try: - self._logger.debug("Requesting {0} on endpoint {1}".format(str(request.__name__), str(endpoint))) - async with aiohttp.ClientSession() as session: - json_data = await request(endpoint.conn_handler(session), **req_args) - return json_data - except (ClientError, ServerDisconnectedError, gaierror, - asyncio.TimeoutError, ValueError, jsonschema.ValidationError) as e: - self._logger.debug(str(e)) - tries += 1 + tries = 0 + while tries < 3 and endpoints: + endpoint = random.choice(endpoints) + endpoints.remove(endpoint) + try: + self._logger.debug("Requesting {0} on endpoint {1}".format(str(request.__name__), str(endpoint))) + async with aiohttp.ClientSession() as session: + json_data = await request(endpoint.conn_handler(session), **req_args) + return json_data + except (ClientError, ServerDisconnectedError, gaierror, + asyncio.TimeoutError, ValueError, jsonschema.ValidationError) as e: + self._logger.debug(str(e)) + tries += 1 raise NoPeerAvailable("", len(endpoints)) async def broadcast(self, currency, request, req_args={}): diff --git a/src/sakia/gui/dialogs/connection_cfg/model.py b/src/sakia/gui/dialogs/connection_cfg/model.py index 04296830f4e724ec838f658c9606d1ad82a3de4e..322b1012635d6cb0ea6c4000fc596f3e57eb85f0 100644 --- a/src/sakia/gui/dialogs/connection_cfg/model.py +++ b/src/sakia/gui/dialogs/connection_cfg/model.py @@ -172,8 +172,7 @@ class ConnectionConfigModel(QObject): registered = parser(data) tries += 1 except errors.DuniterError as e: - if e.ucode in (errors.NO_MEMBER_MATCHING_PUB_OR_UID, - e.ucode == errors.NO_MATCHING_IDENTITY): + if e.ucode in (errors.NO_MEMBER_MATCHING_PUB_OR_UID, errors.NO_MATCHING_IDENTITY): tries += 1 else: raise