From 5091380133f9db1794f61c292cf0e35316fe74ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Sat, 15 Dec 2018 01:07:02 +0100 Subject: [PATCH] Implement testing the removal of IO pipes on server stop --- pipe_io_server/pipe_io_server.py | 3 ++- tests.py | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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