From c050677692d9d7958697384d7419d5f0d30d44b8 Mon Sep 17 00:00:00 2001 From: Owen W. Taylor Date: Aug 21 2017 18:18:04 +0000 Subject: messaging: do nothing if messaging backend is unset It can be useful to run without a messaging backend for testing purposes (or even in production.) So if the messaging backend is unset, don't send messages rather than erroring out. Signed-off-by: Owen W. Taylor --- diff --git a/server/odcs/server/messaging.py b/server/odcs/server/messaging.py index beba463..e6f99b3 100644 --- a/server/odcs/server/messaging.py +++ b/server/odcs/server/messaging.py @@ -34,7 +34,8 @@ __all__ = ('publish',) def publish(msgs): """Start to send messages to message broker""" backend = _get_messaging_backend() - backend(msgs) + if backend is not None: + backend(msgs) def _umb_send_msg(msgs): @@ -62,6 +63,8 @@ def _get_messaging_backend(): if conf.messaging_backend == 'rhmsg': return _umb_send_msg # TODO: elif conf.messaging_backend == 'fedmsg': - else: + elif conf.messaging_backend: raise ValueError( 'Unknown messaging backend {0}'.format(conf.messaging_backend)) + else: + return None