From c6aebe91d210763f8206d20a73d6b1f12c8b43c9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 4 Jun 2023 16:06:37 +0200 Subject: [PATCH] Continued: - retrieving nodeinfo shouldn't take that long --- config.defaults.json | 2 ++ fba/fba.py | 4 ++-- fba/instances.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/config.defaults.json b/config.defaults.json index 1b1cfb7..9fba2c1 100644 --- a/config.defaults.json +++ b/config.defaults.json @@ -6,6 +6,8 @@ "useragent" : "Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Firefox/113.0", "connection_timeout": 30, "read_timeout" : 5, + "nodeinfo_connection_timeout": 3, + "nodeinfo_read_timeout" : 2, "bot_enabled" : false, "bot_instance" : "https://example.com", "bot_token" : "", diff --git a/fba/fba.py b/fba/fba.py index 623e5e0..a94558e 100644 --- a/fba/fba.py +++ b/fba/fba.py @@ -740,7 +740,7 @@ def fetch_nodeinfo(domain: str, path: str = None) -> list: try: # DEBUG: print("DEBUG: Fetching request:", request) - res = reqto.get(request, headers=api_headers, timeout=(config.get("connection_timeout"), config.get("read_timeout"))) + res = reqto.get(request, headers=api_headers, timeout=(config.get("nodeinfo_connection_timeout"), config.get("nodeinfo_read_timeout"))) data = json_from_response(res) # DEBUG: print(f"DEBUG: res.ok={res.ok},res.status_code={res.status_code},data[]='{type(data)}'") @@ -776,7 +776,7 @@ def fetch_wellknown_nodeinfo(domain: str) -> list: data = {} try: - res = reqto.get(f"https://{domain}/.well-known/nodeinfo", headers=api_headers, timeout=(config.get("connection_timeout"), config.get("read_timeout"))) + res = reqto.get(f"https://{domain}/.well-known/nodeinfo", headers=api_headers, timeout=(config.get("nodeinfo_connection_timeout"), config.get("nodeinfo_read_timeout"))) data = json_from_response(res) # DEBUG: print("DEBUG: domain,res.ok,data[]:", domain, res.ok, type(data)) diff --git a/fba/instances.py b/fba/instances.py index 8be7a38..b21e85b 100644 --- a/fba/instances.py +++ b/fba/instances.py @@ -90,7 +90,7 @@ def update_instance_data(domain: str): elif not has_pending_instance_data(domain): raise Exception(f"Domain '{domain}' has no pending instance data, but function invoked") - # DEBUG: print(f"DEBUG: Updating nodeinfo for domain='{domain}' ...") + # DEBUG: print(f"DEBUG: Updating instance data for domain='{domain}' ...") sql_string = '' fields = list() for key in _pending: -- 2.39.5