diff --git a/CveXplore/main.py b/CveXplore/main.py index 196e2d4c..ed7e8156 100644 --- a/CveXplore/main.py +++ b/CveXplore/main.py @@ -44,7 +44,14 @@ from CveXplore.errors.datasource import UnsupportedDatasourceException from CveXplore.errors.validation import CveNumberValidationError from CveXplore.objects.cvexplore_object import CveXploreObject -from CveXplore.core.celery_task_handler.task_handler import TaskHandler + +try: + from CveXplore.core.celery_task_handler.task_handler import TaskHandler +except ModuleNotFoundError: + # This is not a problem, because using the Celery backend is optional. + # This exception will be handled when loading the TaskHandler fails with + # a NameError, because we already have logging available there. + pass def _version(): @@ -194,7 +201,13 @@ def __init__(self, **kwargs): self.capec = CapecDatabaseFunctions(collection="capec") self.cwe = CWEDatabaseFunctions(collection="cwe") - self.task_handler = TaskHandler() + try: + self.task_handler = TaskHandler() + except NameError: + self.logger.info( + "Failed to load Celery TaskHandler; " + "continuing without the optional Celery backend." + ) self.logger.info(f"Initialized CveXplore version: {self.version}")