From: Marcel van der Veldt Date: Fri, 7 Mar 2025 23:55:24 +0000 (+0100) Subject: Fix: prevent high cpu when filling cache X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=acfb0ba9f985b37c5f1f8c71cf1c03edfb5ea7e5;p=music-assistant-server.git Fix: prevent high cpu when filling cache yield to eventloop to allow headroom for other tasks to be executed --- diff --git a/music_assistant/helpers/audio.py b/music_assistant/helpers/audio.py index a6aea760..d71b4fdd 100644 --- a/music_assistant/helpers/audio.py +++ b/music_assistant/helpers/audio.py @@ -116,6 +116,7 @@ class StreamCache: else: yield chunk del chunk + await asyncio.sleep(0) # yield to eventloop finally: self._subscribers -= 1 if self._subscribers == 0: @@ -157,10 +158,12 @@ class StreamCache: input_format=self.streamdetails.audio_format, output_format=self.streamdetails.audio_format, extra_input_args=extra_input_args, + chunk_size=64000, ): async with self._lock: self._data += chunk del chunk + await asyncio.sleep(0) # yield to eventloop if not self._first_part_received.is_set(): self._first_part_received.set() self.logger.debug(