From 8657799f1469d2495c06087e88aca2777d425806 Mon Sep 17 00:00:00 2001 From: tierno Date: Thu, 10 May 2018 16:51:17 +0200 Subject: [PATCH] fixed double yaml safe at msgkafka write Change-Id: I4dcf13a1a4e14834dd7017647e5fe52301730555 Signed-off-by: tierno --- osm_common/__init__.py | 4 ++-- osm_common/msgkafka.py | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/osm_common/__init__.py b/osm_common/__init__.py index 30a016f..4ed9a8f 100644 --- a/osm_common/__init__.py +++ b/osm_common/__init__.py @@ -1,2 +1,2 @@ -version = '0.1.3' -date_version = '2018-04-25' +version = '0.1.4' +date_version = '2018-05-10' diff --git a/osm_common/msgkafka.py b/osm_common/msgkafka.py index 382bdef..2d82f97 100644 --- a/osm_common/msgkafka.py +++ b/osm_common/msgkafka.py @@ -41,17 +41,22 @@ class MsgKafka(MsgBase): raise MsgException(str(e)) def write(self, topic, key, msg): + """ + Write a message at kafka bus + :param topic: message topic, must be string + :param key: message key, must be string + :param msg: message content, can be string or dictionary + :return: None or raises MsgException on failing + """ try: - self.loop.run_until_complete(self.aiowrite(topic=topic, key=key, - msg=yaml.safe_dump(msg, default_flow_style=True), - loop=self.loop)) + self.loop.run_until_complete(self.aiowrite(topic=topic, key=key, msg=msg)) except Exception as e: raise MsgException("Error writing {} topic: {}".format(topic, str(e))) def read(self, topic): """ - Read from one or several topics. it is non blocking returning None if nothing is available + Read from one or several topics. :param topic: can be str: single topic; or str list: several topics :return: topic, key, message; or None """ -- 2.25.1