Add support for initializing pipes with specific permissions
This commit is contained in:
parent
aa7eea6242
commit
9ccb05a709
@ -1,4 +1,4 @@
|
||||
from os import mkfifo, remove
|
||||
from os import mkfifo, remove, chmod
|
||||
from os.path import exists
|
||||
|
||||
|
||||
@ -6,13 +6,11 @@ class Pipe:
|
||||
def __init__(self, path):
|
||||
self.path = path
|
||||
|
||||
def recreate(self):
|
||||
def recreate(self, permissions):
|
||||
self.remove()
|
||||
self.create()
|
||||
mkfifo(self.path)
|
||||
chmod(self.path, permissions)
|
||||
|
||||
def remove(self):
|
||||
if exists(self.path):
|
||||
remove(self.path)
|
||||
|
||||
def create(self):
|
||||
mkfifo(self.path)
|
||||
|
@ -8,17 +8,17 @@ from .terminate_process_on_failure import terminate_process_on_failure
|
||||
|
||||
|
||||
class PipeIOServer(ABC, Thread):
|
||||
def __init__(self, in_pipe=None, out_pipe=None):
|
||||
def __init__(self, in_pipe=None, out_pipe=None, permissions=0o700):
|
||||
super().__init__()
|
||||
self._in_pipe, self._out_pipe = in_pipe, out_pipe
|
||||
self._create_pipes()
|
||||
self._create_pipes(permissions)
|
||||
self._stop_event = Event()
|
||||
self._reader_thread, self._writer_thread = self._create_io_threads()
|
||||
self._io_threads = (self._reader_thread, self._writer_thread)
|
||||
|
||||
def _create_pipes(self):
|
||||
Pipe(self.in_pipe).recreate()
|
||||
Pipe(self.out_pipe).recreate()
|
||||
def _create_pipes(self, permissions):
|
||||
Pipe(self.in_pipe).recreate(permissions)
|
||||
Pipe(self.out_pipe).recreate(permissions)
|
||||
|
||||
@property
|
||||
def in_pipe(self):
|
||||
|
Loading…
Reference in New Issue
Block a user