Terminate process with stacktrace if PipeReaderThread fails

This commit is contained in:
Kristóf Tóth 2018-12-14 16:35:08 +01:00
parent a8d73483cf
commit 300817fe70

View File

@ -1,10 +1,12 @@
from threading import Thread
from queue import Queue
from os import mkfifo, remove
from os import mkfifo, remove, getpid, kill
from os.path import exists, join
from signal import SIGTERM
from secrets import token_urlsafe
from collections import namedtuple
from abc import ABC, abstractmethod
from traceback import print_exc
class PipeWriterThread(Thread):
@ -43,7 +45,11 @@ class PipeReaderThread(Thread):
message = pipe.read()
if message == self._stop_sequence:
break
try:
self._message_handler(message)
except:
print_exc()
kill(getpid(), SIGTERM)
def stop(self):
with open(self._pipe_path, 'wb') as pipe: