From 4615edcaf88a86f192f3dc9c9faa5c295dcfc9a3 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Sun, 22 Feb 2026 02:19:59 +0100 Subject: [PATCH] Add some additional guards to asyncprocess --- music_assistant/helpers/process.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/music_assistant/helpers/process.py b/music_assistant/helpers/process.py index 1da3541f..090df1ee 100644 --- a/music_assistant/helpers/process.py +++ b/music_assistant/helpers/process.py @@ -171,10 +171,10 @@ class AsyncProcess: async def write(self, data: bytes) -> None: """Write data to process stdin.""" - if self._close_called: + if self._close_called or self.proc is None: + return + if self.proc.stdin is None: return - assert self.proc is not None # for type checking - assert self.proc.stdin is not None # for type checking async with self._stdin_lock: self.proc.stdin.write(data) with suppress(BrokenPipeError, ConnectionResetError): @@ -182,10 +182,10 @@ class AsyncProcess: async def write_eof(self) -> None: """Write end of file to to process stdin.""" - if self._close_called: + if self._close_called or self.proc is None: + return + if self.proc.stdin is None: return - assert self.proc is not None # for type checking - assert self.proc.stdin is not None # for type checking async with self._stdin_lock: try: if self.proc.stdin.can_write_eof(): -- 2.34.1