From 6cd598fc4f1008e05f083dfdeb5f8c2903776030 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ebbe=20Ba=C3=9F?= Date: Thu, 15 Feb 2024 11:40:55 +0100 Subject: [PATCH] added clean exit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ebbe Baß --- server/app.py | 4 +++- server/exampleReceiver.py | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/server/app.py b/server/app.py index 84e1986..adf08d8 100644 --- a/server/app.py +++ b/server/app.py @@ -7,6 +7,7 @@ import python_artnet as Artnet import os from getmac import get_mac_address import time +import sys app = Flask(__name__) @@ -137,7 +138,8 @@ def start_mqtt_publishers(): except Exception as e: print(e) except KeyboardInterrupt: - break + artNet.close() + sys.exit() except Exception as e: print(e) diff --git a/server/exampleReceiver.py b/server/exampleReceiver.py index dd8e2c5..6dbd804 100644 --- a/server/exampleReceiver.py +++ b/server/exampleReceiver.py @@ -23,18 +23,18 @@ tuple_ip = (str(get_eth0_ip()), 6454) artNet.art_pol_reply(tuple_ip) artNetPacket = artNet.readPacket() print(type(artNetPacket.universe)) -# while True: -# try: -# # Gets whatever the last Art-Net packet we received is -# artNetPacket = artNet.readPacket() -# # Make sure we actually *have* a packet -# if artNetPacket is not None and artNetPacket.data is not None: -# print("Universe: "+str(artNetPacket.universe)) -# # Stores the packet data array -# dmxPacket = artNetPacket.data +while True: + try: + # Gets whatever the last Art-Net packet we received is + artNetPacket = artNet.readPacket() + # Make sure we actually *have* a packet + if artNetPacket is not None and artNetPacket.data is not None: + print("Universe: "+str(artNetPacket.universe)) + # Stores the packet data array + dmxPacket = artNetPacket.data -# except KeyboardInterrupt: -# break + except KeyboardInterrupt: + break # Close the various connections cleanly so nothing explodes :) artNet.close()