From: Marcel van der Veldt Date: Fri, 12 Apr 2024 09:08:25 +0000 (+0200) Subject: cleanup X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=4d80a896b674c34028b772af0094f38173cdd9cf;p=music-assistant-server.git cleanup --- diff --git a/music_assistant/server/helpers/audio.py b/music_assistant/server/helpers/audio.py index 8dfa838f..648cb3d1 100644 --- a/music_assistant/server/helpers/audio.py +++ b/music_assistant/server/helpers/audio.py @@ -143,11 +143,12 @@ class FFMpeg(AsyncProcess): self.proc.stdin.close() await asyncio.sleep(0) # yield to loop # abort existing readers on stdout first before we send communicate - if self.proc.stdout: - if self.proc.stdout._waiter is not None: - with suppress(asyncio.exceptions.InvalidStateError): - self.proc.stdout._waiter.set_exception(asyncio.CancelledError()) - # read reamaing bytes to unblock pipe + waiter: asyncio.Future + if self.proc.stdout and (waiter := self.proc.stdout._waiter): + self.proc.stdout._waiter = None + if waiter and not waiter.done(): + waiter.set_exception(asyncio.CancelledError()) + # read remaining bytes to unblock pipe await self.read(-1) # wait for log task to complete that reads the remaining data from stderr with suppress(TimeoutError):