Improve exceptions

This commit is contained in:
dmunozv04
2025-01-24 16:43:39 +01:00
parent f75dff8faf
commit 6f4c27c0a5
3 changed files with 13 additions and 13 deletions

View File

@@ -38,14 +38,14 @@ class DeviceListener:
await asyncio.sleep(60 * 60 * 24) # Refresh every 24 hours
try:
await self.lounge_controller.refresh_auth()
except:
except BaseException:
# traceback.print_exc()
pass
async def is_available(self):
try:
return await self.lounge_controller.is_available()
except:
except BaseException:
# traceback.print_exc()
return False
@@ -57,20 +57,20 @@ class DeviceListener:
try:
self.logger.debug("Refreshing auth")
await lounge_controller.refresh_auth()
except:
except BaseException:
await asyncio.sleep(10)
while not (await self.is_available()) and not self.cancelled:
await asyncio.sleep(10)
try:
await lounge_controller.connect()
except:
except BaseException:
pass
while not lounge_controller.connected() and not self.cancelled:
# Doesn't connect to the device if it's a kids profile (it's broken)
await asyncio.sleep(10)
try:
await lounge_controller.connect()
except:
except BaseException:
pass
self.logger.info(
"Connected to device %s (%s)", lounge_controller.screen_name, self.name
@@ -79,14 +79,14 @@ class DeviceListener:
self.logger.info("Subscribing to lounge")
sub = await lounge_controller.subscribe_monitored(self)
await sub
except:
except BaseException:
pass
# Method called on playback state change
async def __call__(self, state):
try:
self.task.cancel()
except:
except BaseException:
pass
time_start = time.time()
self.task = asyncio.create_task(self.process_playstatus(state, time_start))

View File

@@ -347,7 +347,7 @@ class AddDevice(ModalWithClickExit):
paired = False
try:
paired = await lounge_controller.pair(pairing_code)
except:
except BaseException:
pass
if paired:
device = {
@@ -496,7 +496,7 @@ class AddChannel(ModalWithClickExit):
self.query_one("#channel-search-results").remove_children()
try:
channels_list = await self.api_helper.search_channels(channel_name)
except:
except BaseException:
self.query_one("#add-channel-info").update(
"[#ff0000]Failed to search for channel"
)
@@ -943,7 +943,7 @@ class ISponsorBlockTVSetupMainScreen(Screen):
self.app.query_one("#warning-no-key").display = (
not event.input.value
) and self.config.channel_whitelist
except:
except BaseException:
pass

View File

@@ -44,7 +44,7 @@ class YtLoungeApi(pyytlounge.YtLoungeApi):
) # YouTube sends at least a message every 30 seconds (no-op or any other)
try:
self.subscribe_task.cancel()
except Exception:
except BaseException:
pass
# Subscribe to the lounge and start the watchdog
@@ -52,7 +52,7 @@ class YtLoungeApi(pyytlounge.YtLoungeApi):
self.callback = callback
try:
self.subscribe_task_watchdog.cancel()
except:
except BaseException:
pass # No watchdog task
self.subscribe_task = asyncio.create_task(super().subscribe(callback))
self.subscribe_task_watchdog = asyncio.create_task(self._watchdog())
@@ -64,7 +64,7 @@ class YtLoungeApi(pyytlounge.YtLoungeApi):
# (Re)start the watchdog
try:
self.subscribe_task_watchdog.cancel()
except:
except BaseException:
pass
finally:
self.subscribe_task_watchdog = asyncio.create_task(self._watchdog())