Cleanup correctly (#15043)

This commit is contained in:
Nicolas Mowen 2024-11-17 15:57:58 -07:00 committed by GitHub
parent 5b1b6b5be0
commit 474c248c9d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 4 deletions

View File

@ -91,6 +91,7 @@ class FrigateApp:
self.processes: dict[str, int] = {} self.processes: dict[str, int] = {}
self.embeddings: Optional[EmbeddingsContext] = None self.embeddings: Optional[EmbeddingsContext] = None
self.region_grids: dict[str, list[list[dict[str, int]]]] = {} self.region_grids: dict[str, list[list[dict[str, int]]]] = {}
self.frame_manager = SharedMemoryFrameManager()
self.config = config self.config = config
def ensure_dirs(self) -> None: def ensure_dirs(self) -> None:
@ -426,7 +427,6 @@ class FrigateApp:
def start_camera_capture_processes(self) -> None: def start_camera_capture_processes(self) -> None:
shm_frame_count = self.shm_frame_count() shm_frame_count = self.shm_frame_count()
frame_manager = SharedMemoryFrameManager()
for name, config in self.config.cameras.items(): for name, config in self.config.cameras.items():
if not self.config.cameras[name].enabled: if not self.config.cameras[name].enabled:
@ -436,7 +436,7 @@ class FrigateApp:
# pre-create shms # pre-create shms
for i in range(shm_frame_count): for i in range(shm_frame_count):
frame_size = config.frame_shape_yuv[0] * config.frame_shape_yuv[1] 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( capture_process = util.Process(
target=capture_camera, target=capture_camera,
@ -717,6 +717,7 @@ class FrigateApp:
self.event_metadata_updater.stop() self.event_metadata_updater.stop()
self.inter_zmq_proxy.stop() self.inter_zmq_proxy.stop()
self.frame_manager.cleanup()
while len(self.detection_shms) > 0: while len(self.detection_shms) > 0:
shm = self.detection_shms.pop() shm = self.detection_shms.pop()
shm.close() shm.close()

View File

@ -145,8 +145,6 @@ def capture_frames(
frame_index = 0 if frame_index == shm_frame_count - 1 else frame_index + 1 frame_index = 0 if frame_index == shm_frame_count - 1 else frame_index + 1
frame_manager.cleanup()
class CameraWatchdog(threading.Thread): class CameraWatchdog(threading.Thread):
def __init__( def __init__(