forked from platypush/platypush
Initialize the local fifo only when the backend is run
This commit is contained in:
parent
898a4ffdef
commit
c62a1a2bd3
1 changed files with 4 additions and 4 deletions
|
@ -8,10 +8,6 @@ from .. import Backend
|
||||||
class LocalBackend(Backend):
|
class LocalBackend(Backend):
|
||||||
def _init(self, fifo):
|
def _init(self, fifo):
|
||||||
self.fifo = fifo
|
self.fifo = fifo
|
||||||
try: os.mkfifo(self.fifo)
|
|
||||||
except FileExistsError as e: pass
|
|
||||||
logging.info('Initialized local backend on fifo {}'.format(self.fifo))
|
|
||||||
|
|
||||||
def send_msg(self, msg):
|
def send_msg(self, msg):
|
||||||
if isinstance(msg, dict):
|
if isinstance(msg, dict):
|
||||||
msg = json.dumps(msg)
|
msg = json.dumps(msg)
|
||||||
|
@ -24,6 +20,10 @@ class LocalBackend(Backend):
|
||||||
f.write(msg)
|
f.write(msg)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
try: os.mkfifo(self.fifo)
|
||||||
|
except FileExistsError as e: pass
|
||||||
|
logging.info('Initialized local backend on fifo {}'.format(self.fifo))
|
||||||
|
|
||||||
with open(self.fifo, 'rb', 0) as f:
|
with open(self.fifo, 'rb', 0) as f:
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue