Skip to content

armgit / mwmbl

Public Imported from GitHub
0

An open source, non-profit web search engine

Wrap background tasks in try/except

Daoud Clarkee9835edc452f
diff --git a/mwmbl/background.py b/mwmbl/background.py
index 12a933e..858ea11 100644
--- a/mwmbl/background.py
+++ b/mwmbl/background.py
@@ -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")