Skip to content

Commit ab6f245

Browse files
committed
Prevent command write from blocking in the absence of a reader
1 parent f9a8693 commit ab6f245

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

music_assistant/helpers/named_pipe.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ async def write(self, data: bytes, log_slow_writes: bool = True) -> None:
5555
start_time = time.time()
5656

5757
def _write() -> None:
58-
with open(self._pipe_path, "wb", buffering=0) as pipe_file:
58+
# use mode r+b to open read/write, which prevents writes from blocking
59+
# in the absence of a reader at the time of write
60+
with open(self._pipe_path, "r+b", buffering=0) as pipe_file:
5961
pipe_file.write(data)
6062

6163
# Run blocking write in thread pool

0 commit comments

Comments
 (0)