INNER CODE UNIT · Python

monitor_queue

bkbilly/lnxlink · lnxlink/__main__.py:325

    def monitor_queue(self):
        """Loop through the queue list and publish data to MQTT broker"""
        while not self.stop_event.is_set():
            if not self.kill:
                name, queue_data = self.publ_queue.get_item(timeout=0.5)
                if name is not None and queue_data is not None:
                    pub_data, retain, force_publish = queue_data
                    self.publish_monitor_data(name, pub_data, retain, force_publish)
            else:
                if self.stop_event.wait(timeout=0.2):
                    break
        self.mqtt.send_lwt("OFF")
        logger.info("Stopped monitor_queue")

    def on_connect(self, client, userdata, flags, rcode, *args):
        """Callback for MQTT connect which reports the connection status
        back to MQTT server"""
        logger.info("MQTT connection: %s", self.mqtt.get_rcode_name(rcode))

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…