moved the updater out of a seperate function the worked as a multiprocess because the global var wasnt shared between the processes
Signed-off-by: Ebbe Baß <ebbe.bass>main
parent
3ba023229d
commit
7affda9c98
|
@ -145,20 +145,16 @@ def mqtt_publisher():
|
||||||
artNet.close()
|
artNet.close()
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
def update_tube_index():
|
if __name__ == "__main__":
|
||||||
global TUBE_INDEX
|
flask_thread = Process(target=flask_api)
|
||||||
|
flask_thread.start()
|
||||||
|
publisher_thread = Process(target=mqtt_publisher)
|
||||||
|
publisher_thread.start()
|
||||||
|
# Tube index updater
|
||||||
while True:
|
while True:
|
||||||
cur = db.cursor()
|
cur = db.cursor()
|
||||||
cur.execute("SELECT mac_address, universe, dmx_address FROM tubes")
|
cur.execute("SELECT mac_address, universe, dmx_address FROM tubes")
|
||||||
TUBE_INDEX = cur.fetchall()
|
TUBE_INDEX = cur.fetchall()
|
||||||
cur.close()
|
cur.close()
|
||||||
print("Updated index: "+str(TUBE_INDEX))
|
print("Updated index: "+str(TUBE_INDEX))
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
tube_index_updater_thread = Process(target=update_tube_index)
|
|
||||||
tube_index_updater_thread.start()
|
|
||||||
flask_thread = Process(target=flask_api)
|
|
||||||
flask_thread.start()
|
|
||||||
publisher_thread = Process(target=mqtt_publisher)
|
|
||||||
publisher_thread.start()
|
|
Loading…
Reference in New Issue