]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Wed, 26 Jul 2023 14:51:06 +0000 (16:51 +0200)
committerRoland Häder <roland@mxchange.org>
Wed, 26 Jul 2023 14:51:06 +0000 (16:51 +0200)
- command fetch_relays() should be locked
- fixed exception when row[column] is NoneType

fba/commands.py
fba/models/instances.py

index cd7deb975a24282b5b1807b943babf4a70bb43d7..b8866b59b8a848febee9fd3b789c26a1986d2aa3 100644 (file)
@@ -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:
index 69b6f15c6047d0ac593c8be9752fb6e78af89db1..2f6f8269f8cb55cbb7b580089403ce9a3e8c1963 100644 (file)
@@ -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)