From 2aa673d2c970bec11e400e0df8b9380ae95242bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Sun, 16 Dec 2018 23:28:33 +0100 Subject: [PATCH] Make pipe path attributes of PipeIOServer properties --- pipe_io_server/pipe_io_server.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pipe_io_server/pipe_io_server.py b/pipe_io_server/pipe_io_server.py index bba85ae..33d6772 100644 --- a/pipe_io_server/pipe_io_server.py +++ b/pipe_io_server/pipe_io_server.py @@ -10,7 +10,7 @@ from .pipe import Pipe class PipeIOServer(ABC): def __init__(self, in_pipe=None, out_pipe=None): - self.in_pipe, self.out_pipe = in_pipe, out_pipe + self._in_pipe, self._out_pipe = in_pipe, out_pipe self._io_threads = None self._create_pipes() self._init_io_threads() @@ -18,11 +18,19 @@ class PipeIOServer(ABC): def _create_pipes(self): if not self.in_pipe or not self.out_pipe: pipe_id = token_urlsafe(6) - self.in_pipe = join('/tmp', f'in_pipe_{pipe_id}') - self.out_pipe = join('/tmp', f'out_pipe_{pipe_id}') + self._in_pipe = join('/tmp', f'in_pipe_{pipe_id}') + self._out_pipe = join('/tmp', f'out_pipe_{pipe_id}') Pipe(self.in_pipe).recreate() Pipe(self.out_pipe).recreate() + @property + def in_pipe(self): + return self._in_pipe + + @property + def out_pipe(self): + return self._out_pipe + def _init_io_threads(self): io_threads_dict = { 'reader': PipeReaderThread(self.in_pipe, self.handle_message),