From: marcelveldt Date: Wed, 16 Oct 2019 09:36:28 +0000 (+0200) Subject: tracking memory leakage X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=39a8bc77b67d7216afbf241dd4e2dc95ad861975;p=music-assistant-server.git tracking memory leakage --- diff --git a/music_assistant/http_streamer.py b/music_assistant/http_streamer.py index 72921b1c..fb6a486e 100755 --- a/music_assistant/http_streamer.py +++ b/music_assistant/http_streamer.py @@ -72,7 +72,7 @@ class HTTPStreamer(): except (asyncio.CancelledError, asyncio.TimeoutError): cancelled.set() # wait for bg_task - await asyncio.sleep(1) + await asyncio.sleep(2) del buf_queue raise asyncio.CancelledError() return resp @@ -232,6 +232,7 @@ class HTTPStreamer(): prev_chunk = chunk else: prev_chunk = chunk + del chunk # end of the track reached if cancelled.is_set(): # break out the loop if the http session is cancelled @@ -243,11 +244,12 @@ class HTTPStreamer(): LOGGER.debug("Finished Streaming queue track: %s (%s) on player %s" % (queue_track.item_id, queue_track.name, player.name)) LOGGER.debug("bytes written: %s - duration: %s" % (bytes_written, accurate_duration)) # wait for the queue to consume the data - while buffer.qsize() > 10 and not cancelled.is_set(): - await asyncio.sleep(1) + while not cancelled.is_set() and buffer.qsize() > 4: + await asyncio.sleep(0.5) # end of queue reached, pass last fadeout bits to final output if last_fadeout_data and not cancelled.is_set(): sox_proc.stdin.write(last_fadeout_data) + del last_fadeout_data sox_proc.stdin.close() sox_proc.terminate() LOGGER.info("streaming of queue for player %s completed" % player.name) @@ -320,8 +322,10 @@ class HTTPStreamer(): yield (False, chunk) bytes_sent += len(chunk) buf = new_data[chunksize:] + del chunk else: buf += data + del buf if cancelled.is_set(): return # fire event that streaming has ended for this track (needed by some streaming providers) diff --git a/music_assistant/playerproviders/chromecast.py b/music_assistant/playerproviders/chromecast.py index 2e9539fc..12cdb534 100644 --- a/music_assistant/playerproviders/chromecast.py +++ b/music_assistant/playerproviders/chromecast.py @@ -212,7 +212,7 @@ class ChromecastProvider(PlayerProvider): player.poll_task = True while player.state == PlayerState.Playing: player.cur_time = mediastatus.adjusted_current_time - await asyncio.sleep(5) + await asyncio.sleep(1) player.poll_task = False if not player.poll_task and player.state == PlayerState.Playing: self.mass.event_loop.create_task(poll_task())