From 78cd0fbac15bd84d0ec103eba0da7dd8559e81d0 Mon Sep 17 00:00:00 2001 From: "Manraj Kaur (kaurm105)" Date: Wed, 31 Jul 2024 20:32:59 +0100 Subject: [PATCH] loop thread # Run the MQTT loop for the subscriber in a separate thread subscriber_thread = threading.Thread(target=subscriber_client.loop_forever) subscriber_thread.start() # Run the publisher functions in separate threads energy_thread = threading.Thread(target=publish_energy_data, args=(publisher_client,)) temperature_thread = threading.Thread(target=publish_temperature_data, args=(publisher_client,)) energy_thread.start() temperature_thread.start() # Wait for the threads to complete energy_thread.join() temperature_thread.join()