From b49736c4214737cbdcde23fa4a879388e830bdff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ebbe=20Ba=C3=9F?= Date: Sat, 17 Feb 2024 04:17:25 +0100 Subject: [PATCH] fixed result globalisation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ebbe Baß --- server/app.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/server/app.py b/server/app.py index 0834c0a..2ee60ff 100644 --- a/server/app.py +++ b/server/app.py @@ -109,11 +109,21 @@ def connect_mqtt(): client.connect("localhost", 1883) return client +def update_tube_index(): + while True: + cur = db.cursor() + cur.execute("SELECT mac_address, universe, dmx_address FROM tubes") + global result + result = cur.fetchall() + cur.close() + time.sleep(10) + def start_mqtt_publishers(): # Create and start a thread for each universe mqtt_client = connect_mqtt() artnetBindIp = get_eth0_ip() artNet = Artnet.Artnet(BINDIP = artnetBindIp, DEBUG = True, SHORTNAME = "PiXelTubeMaster", LONGNAME = "PiXelTubeMaster", PORT = 6454) + global result result = None while True: try: @@ -173,15 +183,6 @@ def start_mqtt_publishers(): artNet.close() sys.exit() -def update_tube_index(): - while True: - cur = db.cursor() - cur.execute("SELECT mac_address, universe, dmx_address FROM tubes") - global result - result = cur.fetchall() - cur.close() - time.sleep(10) - if __name__ == "__main__": tube_index_updater_thread = Process(target=update_tube_index) tube_index_updater_thread.start()