From 562435aafccc3d73341e60332c8a33aa6b82aa79 Mon Sep 17 00:00:00 2001 From: delacruzramo Date: Tue, 10 Dec 2019 12:06:01 +0100 Subject: [PATCH] Fix Bug 914: Updating VNFD the first time shows ProducerClosed error Change-Id: I02f9ad72bbc4256954030b4d338af242d1f81b81 Signed-off-by: delacruzramo --- debian/python3-osm-common.postinst | 4 ++-- osm_common/msgkafka.py | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/debian/python3-osm-common.postinst b/debian/python3-osm-common.postinst index 2c60d98..9d91a84 100755 --- a/debian/python3-osm-common.postinst +++ b/debian/python3-osm-common.postinst @@ -20,8 +20,8 @@ echo "POST INSTALL OSM-COMMON" echo "Installing python dependencies via pip..." -pip3 install --upgrade aiokafka==0.4.* -pip3 install --upgrade pymongo==3.7.* +pip3 install --upgrade aiokafka +pip3 install --upgrade pymongo pip3 install --upgrade pyyaml==5.* pip3 install pycrypto # added dependency python3-crypto seems not working diff --git a/osm_common/msgkafka.py b/osm_common/msgkafka.py index 1e22c9f..91775f2 100644 --- a/osm_common/msgkafka.py +++ b/osm_common/msgkafka.py @@ -64,11 +64,15 @@ class MsgKafka(MsgBase): :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=msg)) - - except Exception as e: - raise MsgException("Error writing {} topic: {}".format(topic, str(e))) + retry = 2 # Try two times + while retry: + try: + self.loop.run_until_complete(self.aiowrite(topic=topic, key=key, msg=msg)) + break + except Exception as e: + retry -= 1 + if retry == 0: + raise MsgException("Error writing {} topic: {}".format(topic, str(e))) def read(self, topic): """ -- 2.25.1