diff --git a/pipe_io_server/pipe_reader_thread.py b/pipe_io_server/pipe_reader_thread.py index 2687fcd..3ba6bdc 100644 --- a/pipe_io_server/pipe_reader_thread.py +++ b/pipe_io_server/pipe_reader_thread.py @@ -8,7 +8,7 @@ from .terminate_process_on_failure import terminate_process_on_failure class PipeReaderThread(Thread): eof = b'' - stop_sequence = b'stop_reading' + stop_sequence = b'stop_reading\n' def __init__(self, pipe_path, stop_event, message_handler): super().__init__() @@ -20,11 +20,11 @@ class PipeReaderThread(Thread): def run(self): with open(self._pipe_path, 'rb') as pipe: while True: - message = pipe.readline().rstrip() + message = pipe.readline() if message in (self.eof, self.stop_sequence): self._stop_event.set() break - self._message_handler(message) + self._message_handler(message[:-1]) def stop(self): self.unblock() @@ -33,5 +33,5 @@ class PipeReaderThread(Thread): def unblock(self): with suppress(OSError): fd = osopen(self._pipe_path, O_WRONLY | O_NONBLOCK) - write(fd, self.stop_sequence + b'\n') + write(fd, self.stop_sequence) close(fd)