From 9a833a4cd48e593f5716cd63405b0504084f4896 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 30 Jun 2023 15:22:08 +0200 Subject: [PATCH] Continued: - try/except for fetching peers --- fba/http/federation.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/fba/http/federation.py b/fba/http/federation.py index 844fe28..79385ea 100644 --- a/fba/http/federation.py +++ b/fba/http/federation.py @@ -82,8 +82,12 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path: logger.debug("Updating last_instance_fetch for domain='%s' ...", domain) instances.set_last_instance_fetch(domain) - logger.debug("Fetching instances for domain='%s',software='%s',origin='%s'", domain, software, origin) - peerlist = fetch_peers(domain, software, origin) + peerlist = list() + try: + logger.debug("Fetching instances for domain='%s',software='%s',origin='%s'", domain, software, origin) + peerlist = fetch_peers(domain, software, origin) + except network.exceptions as exception: + logger.warning("Cannot fetch peers from domain='%s': '%s'", domain, type(exception)) logger.debug("peerlist[]='%s'", type(peerlist)) if isinstance(peerlist, list): @@ -91,7 +95,7 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path: instances.set_total_peers(domain, peerlist) logger.debug("peerlist[]='%s'", type(peerlist)) - if peerlist is None: + if peerlist is None or len(peerlist) == 0: logger.warning("Cannot fetch peers: domain='%s'", domain) logger.debug("Invoking cookies.clear(%s) ...", domain) -- 2.39.5