use id of pipe to avoid file system collisions

This commit is contained in:
Jakob Ketterl 2020-08-13 23:51:11 +02:00
parent ddb5fe51b3
commit 5bc69b6fa4
1 changed files with 3 additions and 7 deletions

View File

@ -87,15 +87,11 @@ class Pipe(object):
def __init__(self, path, direction, encoding=None):
self.doOpen = True
self.path = path
self.path = "{base}_{myid}".format(base=path, myid=id(self))
self.direction = direction
self.encoding = encoding
self.file = None
try:
os.unlink(path)
except Exception:
pass
os.mkfifo(path)
os.mkfifo(self.path)
def open(self):
self.file = open(self.path, self.direction, encoding=self.encoding)
@ -247,7 +243,7 @@ class dsp(object):
def set_temporary_directory(self, what):
self.temporary_directory = what
self.pipe_base_path = "{tmp_dir}/openwebrx_pipe_{myid}_".format(tmp_dir=self.temporary_directory, myid=id(self))
self.pipe_base_path = "{tmp_dir}/openwebrx_pipe_".format(tmp_dir=self.temporary_directory)
def chain(self, which):
chain = ["nc -v 127.0.0.1 {nc_port}"]