fix(playout): catch oserror in liquidsoap client

Prevent playout crash when liquidsoap is not yet reachable.
This commit is contained in:
jo 2023-03-29 16:47:13 +02:00 committed by Kyle Robbertze
parent f902537056
commit 6412b17996
4 changed files with 17 additions and 17 deletions

View File

@ -58,7 +58,7 @@ class LiquidsoapClient:
version = self.version()
logger.info("found version %s", version)
return version
except (ConnectionError, TimeoutError) as exception:
except OSError as exception:
logger.warning("could not get version: %s", exception)
timeout -= 1
sleep(1)

View File

@ -53,7 +53,7 @@ class LiquidsoapConnection:
try:
self.connect()
return self
except (ConnectionError, TimeoutError) as exception:
except OSError as exception:
self._sock = None
self._lock.release()
raise exception

View File

@ -151,7 +151,7 @@ class PypoFetch(Thread):
streaming=state.schedule_streaming,
)
except (ConnectionError, TimeoutError) as exception:
except OSError as exception:
logger.exception(exception)
self.pypo_liquidsoap.clear_all_queues()
@ -164,28 +164,28 @@ class PypoFetch(Thread):
) -> None:
try:
self.liq_client.settings_update(message_format=stream_format)
except (ConnectionError, TimeoutError) as exception:
except OSError as exception:
logger.exception(exception)
@ls_timeout
def update_liquidsoap_message_offline(self, message_offline: str) -> None:
try:
self.liq_client.settings_update(message_offline=message_offline)
except (ConnectionError, TimeoutError) as exception:
except OSError as exception:
logger.exception(exception)
@ls_timeout
def update_liquidsoap_transition_fade(self, fade: float) -> None:
try:
self.liq_client.settings_update(input_fade_transition=fade)
except (ConnectionError, TimeoutError) as exception:
except OSError as exception:
logger.exception(exception)
@ls_timeout
def update_liquidsoap_station_name(self, station_name: str) -> None:
try:
self.liq_client.settings_update(station_name=station_name)
except (ConnectionError, TimeoutError) as exception:
except OSError as exception:
logger.exception(exception)
# Process the schedule

View File

@ -53,14 +53,14 @@ class TelnetLiquidsoap:
def queue_clear_all(self):
try:
self.liq_client.queues_remove(*self.queues)
except (ConnectionError, TimeoutError) as exception:
except OSError as exception:
logger.exception(exception)
@ls_timeout
def queue_remove(self, queue_id: int):
try:
self.liq_client.queues_remove(queue_id)
except (ConnectionError, TimeoutError) as exception:
except OSError as exception:
logger.exception(exception)
@ls_timeout
@ -68,21 +68,21 @@ class TelnetLiquidsoap:
try:
annotation = create_liquidsoap_annotation(file_event)
self.liq_client.queue_push(queue_id, annotation, file_event.show_name)
except (ConnectionError, TimeoutError) as exception:
except OSError as exception:
logger.exception(exception)
@ls_timeout
def stop_web_stream_buffer(self):
try:
self.liq_client.web_stream_stop_buffer()
except (ConnectionError, TimeoutError) as exception:
except OSError as exception:
logger.exception(exception)
@ls_timeout
def stop_web_stream_output(self):
try:
self.liq_client.web_stream_stop()
except (ConnectionError, TimeoutError) as exception:
except OSError as exception:
logger.exception(exception)
@ls_timeout
@ -90,7 +90,7 @@ class TelnetLiquidsoap:
try:
self.liq_client.web_stream_start()
self.current_prebuffering_stream_id = None
except (ConnectionError, TimeoutError) as exception:
except OSError as exception:
logger.exception(exception)
@ls_timeout
@ -98,14 +98,14 @@ class TelnetLiquidsoap:
try:
self.liq_client.web_stream_start_buffer(event.row_id, event.uri)
self.current_prebuffering_stream_id = event.row_id
except (ConnectionError, TimeoutError) as exception:
except OSError as exception:
logger.exception(exception)
@ls_timeout
def get_current_stream_id(self) -> str:
try:
return self.liq_client.web_stream_get_id()
except (ConnectionError, TimeoutError) as exception:
except OSError as exception:
logger.exception(exception)
return "-1"
@ -117,7 +117,7 @@ class TelnetLiquidsoap:
try:
logger.debug("Disconnecting source: %s", sourcename)
self.liq_client.source_disconnect(sourcename)
except (ConnectionError, TimeoutError) as exception:
except OSError as exception:
logger.exception(exception)
@ls_timeout
@ -128,5 +128,5 @@ class TelnetLiquidsoap:
try:
logger.debug('Switching source: %s to "%s" status', sourcename, status)
self.liq_client.source_switch_status(sourcename, status == "on")
except (ConnectionError, TimeoutError) as exception:
except OSError as exception:
logger.exception(exception)