diff --git a/platypush/event/__init__.py b/platypush/event/__init__.py index 7e364850e..e2f77fc86 100644 --- a/platypush/event/__init__.py +++ b/platypush/event/__init__.py @@ -1,4 +1,5 @@ import inspect +import logging import threading @@ -9,6 +10,8 @@ class EventGenerator(object): types. Both plugins and backends extend this class. """ + logger = logging.getLogger(__name__) + def __init__(self, *args, **kwargs): self._event_handlers = {} # Event type => callback map @@ -29,7 +32,11 @@ class EventGenerator(object): from platypush.context import get_bus bus = self.bus if isinstance(self, Backend) else get_bus() - bus.post(event) + if not bus: + self.logger.warning('No bus available to post the event: {}'.format(event)) + else: + bus.post(event) + handlers = set() for cls in inspect.getmro(event.__class__):