fix reading embedded images
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Tue, 28 Mar 2023 20:58:54 +0000 (22:58 +0200)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Tue, 28 Mar 2023 20:58:54 +0000 (22:58 +0200)
music_assistant/server/helpers/tags.py

index e4fa31e5027e866b21694ad94a78b9a4f9d8c006..e8b19a82bdaaf5a93a926e0d5172e4afbe6d0d19 100644 (file)
@@ -385,10 +385,13 @@ async def get_embedded_image(input_file: str | AsyncGenerator[bytes, None]) -> b
         if file_path == "-":
             # feed the file contents to the process
             async def chunk_feeder():
-                async for chunk in input_file:
-                    await proc.write(chunk)
-
-                proc.write_eof()
+                try:
+                    async for chunk in input_file:
+                        if proc.closed:
+                            break
+                        await proc.write(chunk)
+                finally:
+                    proc.write_eof()
 
             proc.attach_task(chunk_feeder())