diff --git a/pipe_io_server/pipe_writer_thread.py b/pipe_io_server/pipe_writer_thread.py index 77d3518..c73a057 100644 --- a/pipe_io_server/pipe_writer_thread.py +++ b/pipe_io_server/pipe_writer_thread.py @@ -1,5 +1,8 @@ -from threading import Thread +from contextlib import suppress +from os import O_NONBLOCK, O_RDONLY, close +from os import open as osopen from queue import Queue +from threading import Thread from .terminate_process_on_failure import terminate_process_on_failure @@ -34,4 +37,6 @@ class PipeWriterThread(Thread): def unblock(self): self._write_queue.put(None) - open(self._pipe_path, 'rb').close() + with suppress(OSError): + fd = osopen(self._pipe_path, O_RDONLY | O_NONBLOCK) + close(fd)