From 08805c9f8605f76842471e2c8923b6122f41b33b Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Sat, 6 May 2023 21:29:05 +0100 Subject: [PATCH] Add while loop to prevent crash when DB not ready --- src/main.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main.py b/src/main.py index 365f116..c70d0ec 100644 --- a/src/main.py +++ b/src/main.py @@ -14,7 +14,7 @@ # program. If not, see # https://git.fjla.uk/OwlBoard/db-manager/src/branch/main/LICENSE -version = "2.1.1" +version = "2.1.2" print(f"main.py: Initialising db-manager v{version}") #Third Party Imports @@ -27,9 +27,15 @@ import logger as log log.out("main.py: db-manager Initialised", "INFO") - -#Ensure count document exists in meta: -mongo.metaCounters() + +#Ensure count document exists in meta, wrap in while look to prevent crashing if the DB is not ready: +dbReady = False +while dbReady is False: + try: + mongo.metaCounters() + dbReady = True + except: + dbReady = False #Check & Update corpus/stations: # If older than 12 days then update