From: tierno Date: Thu, 10 May 2018 14:51:17 +0000 (+0200) Subject: fixed double yaml safe at msgkafka write X-Git-Tag: v4.0.0~4 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F23%2F6123%2F1;p=osm%2Fcommon.git fixed double yaml safe at msgkafka write Change-Id: I4dcf13a1a4e14834dd7017647e5fe52301730555 Signed-off-by: tierno --- 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 """