diff --git a/pipe_io_server/pipe_io_server.py b/pipe_io_server/pipe_io_server.py index b68e4f8..8a7398c 100644 --- a/pipe_io_server/pipe_io_server.py +++ b/pipe_io_server/pipe_io_server.py @@ -55,5 +55,6 @@ class PipeIOServer(ABC): def stop(self): for thread in self._io_threads: - thread.stop() + if thread.isAlive(): + thread.stop() PipeHandler(self.in_pipe, self.out_pipe).remove() diff --git a/tests.py b/tests.py index f3ac3da..abcaa7a 100644 --- a/tests.py +++ b/tests.py @@ -44,6 +44,12 @@ def test_echo_server(pipe_io, test_data): assert File(pipe_io.out_pipe).read() == test_data +def test_stop_removes_pipes(pipe_io): + pipe_io.stop() + for path in (pipe_io.in_pipe, pipe_io.out_pipe): + assert not exists(path) + + class File: def __init__(self, path): self.path = path