- try:
- await self.msg_bus.aioread(topics, self._process_msg)
- except Exception as e:
- # Failed to subscribe to kafka topic
- log.exception("Error when subscribing to topics %s", str(topics))
- raise e
+ while True:
+ try:
+ await self.msg_bus.aioread(topics, self._process_msg)
+ break
+ except Exception as e:
+ # Failed to subscribe to kafka topic
+ log.exception("Error when subscribing to topics %s", str(topics))
+ log.exception("Exception %s", str(e))
+ # Wait for some time for kaka to stabilize and then reattempt to subscribe again
+ time.sleep(wait_time)
+ log.info("Retrying to subscribe the kafka topic(s) %s", str(topics))