From ccb5886698f03c8eedf69778c6c1ebb437c8713a Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Sun, 4 Apr 2021 23:14:08 +0100 Subject: [PATCH] Lower CPU a bit with slower loops. --- player.py | 2 +- player_handler.py | 2 +- server.py | 10 +++++----- websocket_server.py | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/player.py b/player.py index 3a4066c..7c4852e 100644 --- a/player.py +++ b/player.py @@ -541,7 +541,7 @@ class Player(): try: while self.running: - time.sleep(0.01) + time.sleep(0.02) self._updateState() self._ping_times() try: diff --git a/player_handler.py b/player_handler.py index b4aa25d..6de6912 100644 --- a/player_handler.py +++ b/player_handler.py @@ -33,7 +33,7 @@ class PlayerHandler(): except: pass - sleep(0.01) + sleep(0.02) # Catch the handler being killed externally. except KeyboardInterrupt: self.logger.log.info("Received KeyboardInterupt") diff --git a/server.py b/server.py index 500ff50..1cdcb8a 100644 --- a/server.py +++ b/server.py @@ -343,7 +343,7 @@ def list_showplans(): except queue.Empty: pass - time.sleep(0.1) + time.sleep(0.02) @app.route("/library/search/") def search_library(type: str): @@ -370,7 +370,7 @@ def search_library(type: str): except queue.Empty: pass - time.sleep(0.1) + time.sleep(0.02) @app.route("/library/playlists/") def get_playlists(type: str): @@ -394,7 +394,7 @@ def get_playlists(type: str): except queue.Empty: pass - time.sleep(0.1) + time.sleep(0.02) @app.route("/library/playlist//") def get_playlist(type: str, library_id: str): @@ -421,7 +421,7 @@ def get_playlist(type: str, library_id: str): except queue.Empty: pass - time.sleep(0.1) + time.sleep(0.02) @app.route("/plan/load/") def load_showplan(timeslotid: int): @@ -455,7 +455,7 @@ def status(channel: int): retries += 1 - time.sleep(0.1) + time.sleep(0.02) @app.route("/quit") diff --git a/websocket_server.py b/websocket_server.py index 1a1d656..14684b2 100644 --- a/websocket_server.py +++ b/websocket_server.py @@ -198,7 +198,7 @@ class WebsocketServer: continue except Exception as e: self.logger.log.exception("Exception trying to send to websocket:", e) - await asyncio.sleep(0.01) + await asyncio.sleep(0.02) self.from_webstudio = asyncio.create_task(handle_from_webstudio()) self.to_webstudio = asyncio.create_task(handle_to_webstudio())