feat(playout): remove stream_setting update handler
This commit is contained in:
parent
f5a83dbabb
commit
2fa045a8ef
|
@ -80,9 +80,6 @@ class PypoMessageHandler(Thread):
|
||||||
elif command == "reset_liquidsoap_bootstrap":
|
elif command == "reset_liquidsoap_bootstrap":
|
||||||
logger.info("Resetting bootstrap vars...")
|
logger.info("Resetting bootstrap vars...")
|
||||||
self.pypo_queue.put(message)
|
self.pypo_queue.put(message)
|
||||||
elif command == "update_stream_setting":
|
|
||||||
logger.info("Updating stream setting...")
|
|
||||||
self.pypo_queue.put(message)
|
|
||||||
elif command == "update_stream_format":
|
elif command == "update_stream_format":
|
||||||
logger.info("Updating stream format...")
|
logger.info("Updating stream format...")
|
||||||
self.pypo_queue.put(message)
|
self.pypo_queue.put(message)
|
||||||
|
|
|
@ -45,9 +45,6 @@ class PypoFetch(Thread):
|
||||||
):
|
):
|
||||||
Thread.__init__(self)
|
Thread.__init__(self)
|
||||||
|
|
||||||
# Hacky...
|
|
||||||
PypoFetch.ref = self
|
|
||||||
|
|
||||||
self.api_client = api_client
|
self.api_client = api_client
|
||||||
self.legacy_client = legacy_client
|
self.legacy_client = legacy_client
|
||||||
self.fetch_queue = fetch_queue
|
self.fetch_queue = fetch_queue
|
||||||
|
@ -86,9 +83,6 @@ class PypoFetch(Thread):
|
||||||
self.process_schedule(self.schedule_data)
|
self.process_schedule(self.schedule_data)
|
||||||
elif command == "reset_liquidsoap_bootstrap":
|
elif command == "reset_liquidsoap_bootstrap":
|
||||||
self.set_bootstrap_variables()
|
self.set_bootstrap_variables()
|
||||||
elif command == "update_stream_setting":
|
|
||||||
logger.info("Updating stream setting...")
|
|
||||||
self.regenerate_liquidsoap_conf(m["setting"])
|
|
||||||
elif command == "update_stream_format":
|
elif command == "update_stream_format":
|
||||||
logger.info("Updating stream format...")
|
logger.info("Updating stream format...")
|
||||||
self.update_liquidsoap_stream_format(m["stream_format"])
|
self.update_liquidsoap_stream_format(m["stream_format"])
|
||||||
|
@ -155,21 +149,6 @@ class PypoFetch(Thread):
|
||||||
self.pypo_liquidsoap.clear_all_queues()
|
self.pypo_liquidsoap.clear_all_queues()
|
||||||
self.pypo_liquidsoap.clear_queue_tracker()
|
self.pypo_liquidsoap.clear_queue_tracker()
|
||||||
|
|
||||||
def restart_liquidsoap(self):
|
|
||||||
try:
|
|
||||||
logger.info("Restarting Liquidsoap")
|
|
||||||
self.liq_client.restart()
|
|
||||||
logger.info("Liquidsoap is up and running")
|
|
||||||
|
|
||||||
except Exception as exception:
|
|
||||||
logger.exception(exception)
|
|
||||||
|
|
||||||
# NOTE: This function is quite short after it was refactored.
|
|
||||||
|
|
||||||
def regenerate_liquidsoap_conf(self, setting):
|
|
||||||
self.restart_liquidsoap()
|
|
||||||
self.update_liquidsoap_connection_status()
|
|
||||||
|
|
||||||
@ls_timeout
|
@ls_timeout
|
||||||
def update_liquidsoap_connection_status(self):
|
def update_liquidsoap_connection_status(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
from .player import fetch
|
|
||||||
|
|
||||||
|
|
||||||
def __timeout(func, timeout_duration, default, args, kwargs):
|
def __timeout(func, timeout_duration, default, args, kwargs):
|
||||||
class InterruptableThread(threading.Thread):
|
class InterruptableThread(threading.Thread):
|
||||||
|
@ -14,27 +12,15 @@ def __timeout(func, timeout_duration, default, args, kwargs):
|
||||||
def run(self):
|
def run(self):
|
||||||
self.result = func(*args, **kwargs)
|
self.result = func(*args, **kwargs)
|
||||||
|
|
||||||
first_attempt = True
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
thread = InterruptableThread()
|
thread = InterruptableThread()
|
||||||
thread.start()
|
thread.start()
|
||||||
if not first_attempt:
|
|
||||||
timeout_duration = timeout_duration * 2
|
|
||||||
thread.join(timeout_duration)
|
thread.join(timeout_duration)
|
||||||
|
|
||||||
if thread.is_alive():
|
if thread.is_alive():
|
||||||
# Restart Liquidsoap and try the command one more time. If it
|
raise Exception("Thread did not terminate")
|
||||||
# fails again then there is something critically wrong...
|
|
||||||
if first_attempt:
|
|
||||||
# restart liquidsoap
|
|
||||||
fetch.PypoFetch.ref.restart_liquidsoap()
|
|
||||||
else:
|
|
||||||
raise Exception("Thread did not terminate")
|
|
||||||
else:
|
|
||||||
return thread.result
|
|
||||||
|
|
||||||
first_attempt = False
|
return thread.result
|
||||||
|
|
||||||
|
|
||||||
def ls_timeout(func, timeout=15, default=None):
|
def ls_timeout(func, timeout=15, default=None):
|
||||||
|
|
Loading…
Reference in New Issue