From da50bacb1e120b85ee067d935792b3c84a8093df Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Sun, 2 Jun 2024 16:56:40 +0200 Subject: [PATCH] short sleep after turning of each led --- podstatus/app.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/podstatus/app.py b/podstatus/app.py index 8ea15d3..98a36e7 100644 --- a/podstatus/app.py +++ b/podstatus/app.py @@ -12,11 +12,6 @@ from config import * -# Configure logging -logging.basicConfig( - level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s" -) - # Initialize the Flask app app = Flask(__name__) app.secret_key = config.FLASK_APP_SECRET_KEY @@ -66,12 +61,7 @@ def turn_off_blinkstick(): logging.info("Turning off BlinkStick") for i in range(config.BLINKSTICK_TOTAL_LED): bstick.set_color(channel=0, index=i, hex="#000000") - - -atexit.register(turn_off_blinkstick) - -# Threading setup -stop_event = Event() + time.sleep(0.1) def set_led_color(pod_index, color): @@ -120,6 +110,11 @@ def background_blinkstick_update(): time.sleep(5) # Add a small delay to prevent high CPU usage +atexit.register(turn_off_blinkstick) + +# Threading setup +stop_event = Event() + # Initialize the background thread and start it background_thread = Thread(target=background_blinkstick_update, daemon=True) background_thread.start()