From: Roland Häder Date: Wed, 26 Jul 2023 14:51:06 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=0d2fd50f7dea5bdd85ee6660d819ce68568d5870;p=fba.git Continued: - command fetch_relays() should be locked - fixed exception when row[column] is NoneType --- diff --git a/fba/commands.py b/fba/commands.py index cd7deb9..b8866b5 100644 --- a/fba/commands.py +++ b/fba/commands.py @@ -1864,6 +1864,9 @@ def fetch_instances_social(args: argparse.Namespace) -> int: def fetch_relays(args: argparse.Namespace) -> int: logger.debug("args[]='%s' - CALLED!", type(args)) + logger.debug("Invoking locking.acquire() ...") + locking.acquire() + if args.domain is not None and args.domain != "": database.cursor.execute("SELECT domain, software FROM instances WHERE software IN ('activityrelay', 'aoderelay', 'selective-relay') AND domain = ? LIMIT 1", [args.domain]) else: diff --git a/fba/models/instances.py b/fba/models/instances.py index 69b6f15..2f6f826 100644 --- a/fba/models/instances.py +++ b/fba/models/instances.py @@ -315,7 +315,10 @@ def is_recent(domain: str, column: str = "last_instance_fetch") -> bool: database.cursor.execute(f"SELECT {column} FROM instances WHERE domain = ? LIMIT 1", [domain]) # Fetch row - fetched = float(database.cursor.fetchone()[column]) + row = database.cursor.fetchone() + + fetched = float(row[column]) if row[column] is not None else 0.0 + diff = (time.time() - fetched) logger.debug("fetched[%s]='%s',key='%s',diff=%f", type(fetched), fetched, key, diff)