diff --git a/pipe_io_server.py b/pipe_io_server.py index 8659583..3141c24 100644 --- a/pipe_io_server.py +++ b/pipe_io_server.py @@ -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 - self._message_handler(message) + try: + self._message_handler(message) + except: + print_exc() + kill(getpid(), SIGTERM) def stop(self): with open(self._pipe_path, 'wb') as pipe: