]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Tue, 21 Nov 2023 18:52:38 +0000 (19:52 +0100)
committerRoland Häder <roland@mxchange.org>
Tue, 21 Nov 2023 18:52:38 +0000 (19:52 +0100)
- also track response time during raised exceptions

fba/http/federation.py
fba/http/network.py

index c17e52d749033d74023cbe95a258c90c93770a6c..b48255de81e71137c536aac76b90b69ed0c70230 100644 (file)
@@ -96,11 +96,8 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path:
     peerlist = list()
     logger.debug("software='%s'", software)
     if software is not None:
-        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',software='%s': '%s'", domain, software, type(exception))
+        logger.debug("Fetching instances for domain='%s',software='%s',origin='%s'", domain, software, origin)
+        peerlist = fetch_peers(domain, software, origin)
 
     logger.debug("peerlist[]='%s'", type(peerlist))
     if isinstance(peerlist, list):
index 1982957dd08794f813d453a6608696fe1af1bacd..91397f971e4cdb4fc0c01f79e530eeb46a048e04 100644 (file)
@@ -258,6 +258,7 @@ def fetch_response(domain: str, path: str, headers: dict, timeout: tuple, allow_
     elif not isinstance(timeout, tuple):
         raise ValueError(f"timeout[]='{type(timeout)}' is not of type 'tuple'")
 
+    start = 0
     try:
         logger.debug("Sending GET request to '%s%s' ...", domain, path)
         start = time.perf_counter()
@@ -276,6 +277,11 @@ def fetch_response(domain: str, path: str, headers: dict, timeout: tuple, allow_
     except exceptions as exception:
         logger.debug("Fetching path='%s' from domain='%s' failed. exception[%s]='%s'", path, domain, type(exception), str(exception))
         instances.set_last_error(domain, exception)
+
+        response_time = time.perf_counter() - start
+        logger.debug("Setting response_time=%s for domain='%s' ...", response_time, domain)
+        instances.set_last_response_time(domain, response_time)
+
         raise exception
 
     logger.debug("response[]='%s' - EXIT!", type(response))