Cleanup process close

This commit is contained in:
Nick Mowen 2023-06-22 17:08:38 -06:00
parent b087d55580
commit f553cb053a

View File

@ -53,8 +53,15 @@ def listen_to_audio(
stop_event = mp.Event()
audio_threads: list[threading.Thread] = []
def exit_process() -> None:
for thread in audio_threads:
thread.join()
logger.info("Exiting audio detector...")
def receiveSignal(signalNumber: int, frame: Optional[FrameType]) -> None:
stop_event.set()
exit_process()
signal.signal(signal.SIGTERM, receiveSignal)
signal.signal(signal.SIGINT, receiveSignal)
@ -69,14 +76,6 @@ def listen_to_audio(
audio_threads.append(audio)
audio.start()
while not stop_event.is_set():
pass
for thread in audio_threads:
thread.join()
logger.info("Exiting audio detector...")
class AudioTfl:
def __init__(self, stop_event: mp.Event):