X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=o2ims%2Fservice%2Fmessagebus.py;h=297aa8f1e1c324b22ec9ecc1a4f94b940f7aa6ce;hb=19ee63847f8eb032009e63634b90eb594f3c0408;hp=07585294bd053d6b2d7fbf97c97d159b36b280bc;hpb=81e3575a77366f30c2049f98c48a3087db0ea992;p=pti%2Fo2.git diff --git a/o2ims/service/messagebus.py b/o2ims/service/messagebus.py index 0758529..297aa8f 100644 --- a/o2ims/service/messagebus.py +++ b/o2ims/service/messagebus.py @@ -14,14 +14,14 @@ # pylint: disable=broad-except, attribute-defined-outside-init from __future__ import annotations -import logging from typing import Callable, Dict, List, Union, Type, TYPE_CHECKING from o2ims.domain import commands, events if TYPE_CHECKING: from . import unit_of_work -logger = logging.getLogger(__name__) +from o2common.helper import o2logging +logger = o2logging.get_logger(__name__) Message = Union[commands.Command, events.Event] @@ -41,7 +41,9 @@ class MessageBus: self.queue = [message] while self.queue: message = self.queue.pop(0) - if isinstance(message, events.Event): + if not message: + continue + elif isinstance(message, events.Event): self.handle_event(message) elif isinstance(message, commands.Command): self.handle_command(message) @@ -65,6 +67,6 @@ class MessageBus: handler = self.command_handlers[type(command)] handler(command) self.queue.extend(self.uow.collect_new_events()) - except Exception: + except Exception as ex: logger.exception("Exception handling command %s", command) - raise + raise ex