CC-5227 - Sometimes Liquidsoap telnet is unresponsive which causes all Pypo threads to block
-initial commit
This commit is contained in:
parent
3391aa90c5
commit
f164cf0ad4
5 changed files with 70 additions and 25 deletions
|
@ -19,6 +19,7 @@ from subprocess import Popen, PIPE
|
|||
|
||||
from api_clients import api_client
|
||||
from std_err_override import LogWriter
|
||||
from timeout import ls_timeout
|
||||
|
||||
|
||||
# configure logging
|
||||
|
@ -38,12 +39,9 @@ signal.signal(signal.SIGINT, keyboardInterruptHandler)
|
|||
|
||||
POLL_INTERVAL = 1800
|
||||
|
||||
config_static = None
|
||||
|
||||
class PypoFetch(Thread):
|
||||
def __init__(self, pypoFetch_q, pypoPush_q, media_q, telnet_lock, pypo_liquidsoap, config):
|
||||
Thread.__init__(self)
|
||||
global config_static
|
||||
|
||||
self.api_client = api_client.AirtimeApiClient()
|
||||
self.fetch_queue = pypoFetch_q
|
||||
|
@ -51,7 +49,6 @@ class PypoFetch(Thread):
|
|||
self.media_prepare_queue = media_q
|
||||
self.last_update_schedule_timestamp = time.time()
|
||||
self.config = config
|
||||
config_static = config
|
||||
self.listener_timeout = POLL_INTERVAL
|
||||
|
||||
self.telnet_lock = telnet_lock
|
||||
|
@ -178,9 +175,17 @@ class PypoFetch(Thread):
|
|||
|
||||
self.pypo_liquidsoap.clear_queue_tracker()
|
||||
|
||||
@ls_timeout
|
||||
def restart_liquidsoap(self):
|
||||
try:
|
||||
self.telnet_lock.acquire()
|
||||
"""do not block - if we receive the lock then good - no other thread
|
||||
will try communicating with Liquidsoap. If we don't receive, it may
|
||||
mean some thread blocked and is still holding the lock. Restarting
|
||||
Liquidsoap will cause that thread to release the lock as an Exception
|
||||
will be thrown."""
|
||||
self.telnet_lock.acquire(False)
|
||||
|
||||
|
||||
self.logger.info("Restarting Liquidsoap")
|
||||
subprocess.call('/etc/init.d/airtime-liquidsoap restart', shell=True)
|
||||
|
||||
|
@ -299,6 +304,7 @@ class PypoFetch(Thread):
|
|||
self.logger.info("No change detected in setting...")
|
||||
self.update_liquidsoap_connection_status()
|
||||
|
||||
@ls_timeout
|
||||
def update_liquidsoap_connection_status(self):
|
||||
"""
|
||||
updates the status of Liquidsoap connection to the streaming server
|
||||
|
@ -345,6 +351,7 @@ class PypoFetch(Thread):
|
|||
self.api_client.notify_liquidsoap_status("OK", stream_id, str(fake_time))
|
||||
|
||||
|
||||
@ls_timeout
|
||||
def update_liquidsoap_stream_format(self, stream_format):
|
||||
# Push stream metadata to liquidsoap
|
||||
# TODO: THIS LIQUIDSOAP STUFF NEEDS TO BE MOVED TO PYPO-PUSH!!!
|
||||
|
@ -361,6 +368,7 @@ class PypoFetch(Thread):
|
|||
finally:
|
||||
self.telnet_lock.release()
|
||||
|
||||
@ls_timeout
|
||||
def update_liquidsoap_transition_fade(self, fade):
|
||||
# Push stream metadata to liquidsoap
|
||||
# TODO: THIS LIQUIDSOAP STUFF NEEDS TO BE MOVED TO PYPO-PUSH!!!
|
||||
|
@ -377,6 +385,7 @@ class PypoFetch(Thread):
|
|||
finally:
|
||||
self.telnet_lock.release()
|
||||
|
||||
@ls_timeout
|
||||
def update_liquidsoap_station_name(self, station_name):
|
||||
# Push stream metadata to liquidsoap
|
||||
# TODO: THIS LIQUIDSOAP STUFF NEEDS TO BE MOVED TO PYPO-PUSH!!!
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue