Fix blocking IO in subsonic provider
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Wed, 24 Jan 2024 11:07:50 +0000 (12:07 +0100)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Wed, 24 Jan 2024 11:07:50 +0000 (12:07 +0100)
music_assistant/server/providers/opensubsonic/sonic_provider.py

index 4e8e5bb52b6b27628a71efe0238b12b0c50362f7..bd3c14bfe38c335a82110df9d049526ae7a20629 100644 (file)
@@ -315,10 +315,14 @@ class OpenSonicProvider(MusicProvider):
     async def _run_async(self, call: Callable, *args, **kwargs):
         return await self.mass.create_task(call, *args, **kwargs)
 
-    async def resolve_image(self, path: str) -> str | bytes | AsyncGenerator[bytes, None]:
+    async def resolve_image(self, path: str) -> bytes:
         """Return the image."""
-        with self._conn.getCoverArt(path) as art:
-            return art.content
+
+        def _get_cover_art() -> bytes:
+            with self._conn.getCoverArt(path) as art:
+                return art.content
+
+        await asyncio.to_thread(_get_cover_art)
 
     async def search(
         self, search_query: str, media_types: list[MediaType] | None = None, limit: int = 20