Skip to content

Commit

Permalink
Make Celery backend optional (#297)
Browse files Browse the repository at this point in the history
  • Loading branch information
oh2fih authored Jun 30, 2024
1 parent c3f81dc commit f3ada21
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions CveXplore/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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}")

Expand Down

0 comments on commit f3ada21

Please sign in to comment.