Make pipe path attributes of PipeIOServer properties
This commit is contained in:
parent
512247163c
commit
2aa673d2c9
@ -10,7 +10,7 @@ from .pipe import Pipe
|
|||||||
|
|
||||||
class PipeIOServer(ABC):
|
class PipeIOServer(ABC):
|
||||||
def __init__(self, in_pipe=None, out_pipe=None):
|
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._io_threads = None
|
||||||
self._create_pipes()
|
self._create_pipes()
|
||||||
self._init_io_threads()
|
self._init_io_threads()
|
||||||
@ -18,11 +18,19 @@ class PipeIOServer(ABC):
|
|||||||
def _create_pipes(self):
|
def _create_pipes(self):
|
||||||
if not self.in_pipe or not self.out_pipe:
|
if not self.in_pipe or not self.out_pipe:
|
||||||
pipe_id = token_urlsafe(6)
|
pipe_id = token_urlsafe(6)
|
||||||
self.in_pipe = join('/tmp', f'in_pipe_{pipe_id}')
|
self._in_pipe = join('/tmp', f'in_pipe_{pipe_id}')
|
||||||
self.out_pipe = join('/tmp', f'out_pipe_{pipe_id}')
|
self._out_pipe = join('/tmp', f'out_pipe_{pipe_id}')
|
||||||
Pipe(self.in_pipe).recreate()
|
Pipe(self.in_pipe).recreate()
|
||||||
Pipe(self.out_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):
|
def _init_io_threads(self):
|
||||||
io_threads_dict = {
|
io_threads_dict = {
|
||||||
'reader': PipeReaderThread(self.in_pipe, self.handle_message),
|
'reader': PipeReaderThread(self.in_pipe, self.handle_message),
|
||||||
|
Loading…
Reference in New Issue
Block a user