Wrap background tasks in try/except

This commit is contained in:
Daoud Clarke 2022-06-30 20:00:38 +01:00
parent 6ea3a95684
commit e9835edc45

View file

@ -1,15 +1,28 @@
"""
Script that updates data in a background process.
"""
from logging import getLogger
from mwmbl.indexer import historical
from mwmbl.indexer.preprocess import run_preprocessing
from mwmbl.indexer.retrieve import retrieve_batches
from mwmbl.indexer.update_pages import run_update
logger = getLogger(__name__)
def run(index_path: str):
historical.run()
while True:
retrieve_batches()
run_preprocessing(index_path)
run_update(index_path)
try:
retrieve_batches()
except Exception:
logger.exception("Error retrieving batches")
try:
run_preprocessing(index_path)
except Exception:
logger.exception("Error preprocessing")
try:
run_update(index_path)
except Exception:
logger.exception("Error running index update")