From f553cb053a7b45ea9de8bd070e0598fefe4afbc2 Mon Sep 17 00:00:00 2001 From: Nick Mowen Date: Thu, 22 Jun 2023 17:08:38 -0600 Subject: [PATCH] Cleanup process close --- frigate/events/audio.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/frigate/events/audio.py b/frigate/events/audio.py index cf85b182d..5e98b7d39 100644 --- a/frigate/events/audio.py +++ b/frigate/events/audio.py @@ -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):