From: Marcel van der Veldt Date: Mon, 11 Apr 2022 08:55:35 +0000 (+0200) Subject: Fix BrokenPipe error (#254) X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=9c3412fd46f872ebff6960cfcfde435413ab34ad;p=music-assistant-server.git Fix BrokenPipe error (#254) --- diff --git a/music_assistant/helpers/process.py b/music_assistant/helpers/process.py index 2f5b09a3..f0f2ea20 100644 --- a/music_assistant/helpers/process.py +++ b/music_assistant/helpers/process.py @@ -101,13 +101,18 @@ class AsyncProcess: try: self._proc.stdin.write(data) await self._proc.stdin.drain() - except (AttributeError, AssertionError, BrokenPipeError) as err: - raise asyncio.CancelledError() from err + except (AttributeError, AssertionError, BrokenPipeError): + # already exited, race condition + pass def write_eof(self) -> None: """Write end of file to to process stdin.""" - if self._proc.stdin.can_write_eof(): - self._proc.stdin.write_eof() + try: + if self._proc.stdin.can_write_eof(): + self._proc.stdin.write_eof() + except (AttributeError, AssertionError, BrokenPipeError): + # already exited, race condition + pass async def communicate(self, input_data: Optional[bytes] = None) -> bytes: """Write bytes to process and read back results."""