From 6f2f9b34fe758560c1810862451a06d36655bfcb Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Tue, 28 Mar 2023 22:58:54 +0200 Subject: [PATCH] fix reading embedded images --- music_assistant/server/helpers/tags.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/music_assistant/server/helpers/tags.py b/music_assistant/server/helpers/tags.py index e4fa31e5..e8b19a82 100644 --- a/music_assistant/server/helpers/tags.py +++ b/music_assistant/server/helpers/tags.py @@ -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()) -- 2.34.1