From 474c248c9d7501ff7e9677578331d4ca4beff476 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Sun, 17 Nov 2024 15:57:58 -0700 Subject: [PATCH] Cleanup correctly (#15043) --- frigate/app.py | 5 +++-- frigate/video.py | 2 -- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/frigate/app.py b/frigate/app.py index f56ed1a8b..6518c1ddf 100644 --- a/frigate/app.py +++ b/frigate/app.py @@ -91,6 +91,7 @@ class FrigateApp: self.processes: dict[str, int] = {} self.embeddings: Optional[EmbeddingsContext] = None self.region_grids: dict[str, list[list[dict[str, int]]]] = {} + self.frame_manager = SharedMemoryFrameManager() self.config = config def ensure_dirs(self) -> None: @@ -426,7 +427,6 @@ class FrigateApp: def start_camera_capture_processes(self) -> None: shm_frame_count = self.shm_frame_count() - frame_manager = SharedMemoryFrameManager() for name, config in self.config.cameras.items(): if not self.config.cameras[name].enabled: @@ -436,7 +436,7 @@ class FrigateApp: # pre-create shms for i in range(shm_frame_count): frame_size = config.frame_shape_yuv[0] * config.frame_shape_yuv[1] - frame_manager.create(f"{config.name}{i}", frame_size) + self.frame_manager.create(f"{config.name}{i}", frame_size) capture_process = util.Process( target=capture_camera, @@ -717,6 +717,7 @@ class FrigateApp: self.event_metadata_updater.stop() self.inter_zmq_proxy.stop() + self.frame_manager.cleanup() while len(self.detection_shms) > 0: shm = self.detection_shms.pop() shm.close() diff --git a/frigate/video.py b/frigate/video.py index 5af3e13f4..96b562e8c 100755 --- a/frigate/video.py +++ b/frigate/video.py @@ -145,8 +145,6 @@ def capture_frames( frame_index = 0 if frame_index == shm_frame_count - 1 else frame_index + 1 - frame_manager.cleanup() - class CameraWatchdog(threading.Thread): def __init__(