notify.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:garage-butler 作者: gurumitts 项目源码 文件源码
def _mq_reconnect(self, force=False):
        if force:
            self.mq_connected = False
        while not self.mq_connected:
            try:
                self.mq_client = mqtt.Client()
                self.mq_client.connect(host=self.broker, keepalive=10)
                self.mq_client.subscribe(MQ_COMMAND_TOPIC)
                self.mq_client.subscribe(MQ_HA_NOTIFY_TOPIC)
                self.mq_client.on_message = self.on_mq_message
                self.on_mq_disconnect = self.on_mq_disconnect
                self.mq_client.loop_start()
                self.mq_connected = True
                _LOG.info("Connected to MQ!")
            except Exception as ex:
                _LOG.error("Could not connect to MQ: {0}".format(ex))
                _LOG.warning("Trying again in 5 seconds...")
                time.sleep(5)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号