"""Start running the music assistant server."""
# initialize loop
self._loop = asyncio.get_event_loop()
- self._loop.set_exception_handler(self.__handle_exception)
+ self._loop.set_exception_handler(__handle_exception)
self._loop.set_debug(self._debug)
# create shared aiohttp ClientSession
self._http_session = aiohttp.ClientSession(
task = self.loop.run_in_executor(None, target, *args, *kwargs) # type: ignore
return task
- def __handle_exception(
- self, loop: asyncio.AbstractEventLoop, context: Dict
- ) -> None:
- """Global exception handler."""
- LOGGER.exception(
- "Caught exception: %s", context.get("exception", context["message"])
- )
- loop.default_exception_handler(context)
-
async def __async_setup_discovery(self) -> None:
"""Make this Music Assistant instance discoverable on the network."""
zeroconf_type = "_music-assistant._tcp.local."
LOGGER.exception("Error preloading module %s: %s", module_name, exc)
else:
LOGGER.debug("Successfully preloaded module %s", module_name)
+
+
+def __handle_exception(loop: asyncio.AbstractEventLoop, context: Dict) -> None:
+ """Global exception handler."""
+ LOGGER.exception(
+ "Caught exception: %s", context.get("exception", context["message"])
+ )
+ loop.default_exception_handler(context)