From 5afda72b84e4b0df7d642a9a7abe9357420c4cc6 Mon Sep 17 00:00:00 2001 From: Blake Blackshear Date: Sat, 29 May 2021 13:33:01 -0500 Subject: [PATCH] handle exit signals --- frigate/app.py | 1 - frigate/output.py | 14 ++++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/frigate/app.py b/frigate/app.py index a58931710..dc9e4cbfe 100644 --- a/frigate/app.py +++ b/frigate/app.py @@ -228,7 +228,6 @@ class FrigateApp: args=( self.config, self.video_output_queue, - self.stop_event, ), ) output_processor.daemon = True diff --git a/frigate/output.py b/frigate/output.py index d6809b1e1..7124f8fb9 100644 --- a/frigate/output.py +++ b/frigate/output.py @@ -1,13 +1,23 @@ import queue +import signal +import multiprocessing as mp from multiprocessing import shared_memory from frigate.util import SharedMemoryFrameManager -def output_frames(config, video_output_queue, stop_event): +def output_frames(config, video_output_queue): + stop_event = mp.Event() + + def receiveSignal(signalNumber, frame): + stop_event.set() + + signal.signal(signal.SIGTERM, receiveSignal) + signal.signal(signal.SIGINT, receiveSignal) + frame_manager = SharedMemoryFrameManager() previous_frames = {} - while True: + while not stop_event.is_set(): try: ( camera,