From fcb554bf5ba208f0943ba3f790b63b2a0e26cb2a Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Sat, 17 Apr 2021 18:28:00 +0100 Subject: [PATCH] Fix API proxy reliabilty by making flask single threaded. --- helpers/myradio_api.py | 8 ++++++-- server.py | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/helpers/myradio_api.py b/helpers/myradio_api.py index 508501f..4f6f90a 100644 --- a/helpers/myradio_api.py +++ b/helpers/myradio_api.py @@ -94,16 +94,20 @@ class MyRadioAPI: if not payload["current"]: self._logException("API did not return a current show.") - return [] if not payload["next"]: self._logException("API did not return a list of next shows.") - return [] shows = [] shows.append(payload["current"]) shows.extend(payload["next"]) + timeslots = [] + # Remove jukebox etc + for show in shows: + if not "timeslot_id" in show: + shows.remove(show) + # TODO filter out jukebox return shows diff --git a/server.py b/server.py index e43a63a..17b019b 100644 --- a/server.py +++ b/server.py @@ -312,6 +312,7 @@ def channel_json(channel: int): @app.route("/plan/list") def list_showplans(): + while not api_from_q.empty(): api_from_q.get() # Just waste any previous status responses. @@ -620,6 +621,7 @@ def startServer(): port=state.state["port"], debug=True, use_reloader=False, + threaded=False # While API handles are singlethreaded. ) global webserver