Terminate process with stacktrace if PipeReaderThread fails
This commit is contained in:
parent
a8d73483cf
commit
300817fe70
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user