diff --git a/frigate/app.py b/frigate/app.py index 05e91324a..27484e43b 100644 --- a/frigate/app.py +++ b/frigate/app.py @@ -4,7 +4,7 @@ import multiprocessing as mp import os import secrets import shutil -from multiprocessing.synchronize import Event as MpEvent +import threading from typing import Any, Optional import psutil @@ -77,7 +77,7 @@ class FrigateApp: # TODO: Fix FrigateConfig usage, so we can properly annotate it here without mypy erroring out. def __init__(self, config: Any) -> None: - self.stop_event: MpEvent = mp.Event() + self.stop_event = threading.Event() self.detection_queue: mp.Queue = mp.Queue() self.detectors: dict[str, ObjectDetectProcess] = {} self.detection_shms: list[mp.shared_memory.SharedMemory] = [] diff --git a/frigate/events/cleanup.py b/frigate/events/cleanup.py index 740449526..38153c9a8 100644 --- a/frigate/events/cleanup.py +++ b/frigate/events/cleanup.py @@ -5,7 +5,6 @@ import logging import os import threading from enum import Enum -from multiprocessing.synchronize import Event as MpEvent from pathlib import Path from frigate.config import FrigateConfig @@ -22,7 +21,7 @@ class EventCleanupType(str, Enum): class EventCleanup(threading.Thread): - def __init__(self, config: FrigateConfig, stop_event: MpEvent): + def __init__(self, config: FrigateConfig, stop_event: threading.Event): super().__init__(name="event_cleanup") self.config = config self.stop_event = stop_event diff --git a/frigate/events/maintainer.py b/frigate/events/maintainer.py index 7895c770c..c4e063e2d 100644 --- a/frigate/events/maintainer.py +++ b/frigate/events/maintainer.py @@ -1,7 +1,6 @@ import logging import threading from multiprocessing import Queue -from multiprocessing.synchronize import Event as MpEvent from typing import Dict from frigate.comms.events_updater import EventEndPublisher, EventUpdateSubscriber @@ -52,7 +51,7 @@ class EventProcessor(threading.Thread): self, config: FrigateConfig, timeline_queue: Queue, - stop_event: MpEvent, + stop_event: threading.Event, ): super().__init__(name="event_processor") self.config = config diff --git a/frigate/object_processing.py b/frigate/object_processing.py index 32f5bea97..3b1915199 100644 --- a/frigate/object_processing.py +++ b/frigate/object_processing.py @@ -6,7 +6,6 @@ import os import queue import threading from collections import Counter, defaultdict -from multiprocessing.synchronize import Event as MpEvent from statistics import median from typing import Callable @@ -919,13 +918,13 @@ class TrackedObjectProcessor(threading.Thread): dispatcher: Dispatcher, tracked_objects_queue, ptz_autotracker_thread, - stop_event, + stop_event: threading.Event, ): super().__init__(name="detected_frames_processor") self.config = config self.dispatcher = dispatcher self.tracked_objects_queue = tracked_objects_queue - self.stop_event: MpEvent = stop_event + self.stop_event = stop_event self.camera_states: dict[str, CameraState] = {} self.frame_manager = SharedMemoryFrameManager() self.last_motion_detected: dict[str, float] = {} diff --git a/frigate/output/birdseye.py b/frigate/output/birdseye.py index c187c77ea..b946a52bb 100644 --- a/frigate/output/birdseye.py +++ b/frigate/output/birdseye.py @@ -4,7 +4,6 @@ import datetime import glob import logging import math -import multiprocessing as mp import os import queue import subprocess as sp @@ -114,7 +113,7 @@ class FFMpegConverter(threading.Thread): self, ffmpeg: FfmpegConfig, input_queue: queue.Queue, - stop_event: mp.Event, + stop_event: threading.Event, in_width: int, in_height: int, out_width: int, @@ -232,7 +231,7 @@ class BroadcastThread(threading.Thread): camera: str, converter: FFMpegConverter, websocket_server, - stop_event: mp.Event, + stop_event: threading.Event, ): super().__init__() self.camera = camera @@ -269,7 +268,7 @@ class BirdsEyeFrameManager: self, config: FrigateConfig, frame_manager: SharedMemoryFrameManager, - stop_event: mp.Event, + stop_event: threading.Event, ): self.config = config self.mode = config.birdseye.mode @@ -718,7 +717,7 @@ class Birdseye: def __init__( self, config: FrigateConfig, - stop_event: mp.Event, + stop_event: threading.Event, websocket_server, ) -> None: self.config = config diff --git a/frigate/output/camera.py b/frigate/output/camera.py index 2311ec659..6ddccb9fa 100644 --- a/frigate/output/camera.py +++ b/frigate/output/camera.py @@ -1,7 +1,6 @@ """Handle outputting individual cameras via jsmpeg.""" import logging -import multiprocessing as mp import queue import subprocess as sp import threading @@ -17,7 +16,7 @@ class FFMpegConverter(threading.Thread): camera: str, ffmpeg: FfmpegConfig, input_queue: queue.Queue, - stop_event: mp.Event, + stop_event: threading.Event, in_width: int, in_height: int, out_width: int, @@ -99,7 +98,7 @@ class BroadcastThread(threading.Thread): camera: str, converter: FFMpegConverter, websocket_server, - stop_event: mp.Event, + stop_event: threading.Event, ): super().__init__() self.camera = camera @@ -133,7 +132,7 @@ class BroadcastThread(threading.Thread): class JsmpegCamera: def __init__( - self, config: CameraConfig, stop_event: mp.Event, websocket_server + self, config: CameraConfig, stop_event: threading.Event, websocket_server ) -> None: self.config = config self.input = queue.Queue(maxsize=config.detect.fps) diff --git a/frigate/ptz/autotrack.py b/frigate/ptz/autotrack.py index 9366dae56..3cc95f82d 100644 --- a/frigate/ptz/autotrack.py +++ b/frigate/ptz/autotrack.py @@ -8,7 +8,6 @@ import threading import time from collections import deque from functools import partial -from multiprocessing.synchronize import Event as MpEvent import cv2 import numpy as np @@ -147,7 +146,7 @@ class PtzAutoTrackerThread(threading.Thread): onvif: OnvifController, ptz_metrics: dict[str, PTZMetrics], dispatcher: Dispatcher, - stop_event: MpEvent, + stop_event: threading.Event, ) -> None: super().__init__(name="ptz_autotracker") self.ptz_autotracker = PtzAutoTracker( @@ -180,7 +179,7 @@ class PtzAutoTracker: onvif: OnvifController, ptz_metrics: PTZMetrics, dispatcher: Dispatcher, - stop_event: MpEvent, + stop_event: threading.Event, ) -> None: self.config = config self.onvif = onvif diff --git a/frigate/record/cleanup.py b/frigate/record/cleanup.py index b70a23b45..bc4f72c7a 100644 --- a/frigate/record/cleanup.py +++ b/frigate/record/cleanup.py @@ -5,7 +5,6 @@ import itertools import logging import os import threading -from multiprocessing.synchronize import Event as MpEvent from pathlib import Path from playhouse.sqlite_ext import SqliteExtDatabase @@ -22,7 +21,7 @@ logger = logging.getLogger(__name__) class RecordingCleanup(threading.Thread): """Cleanup existing recordings based on retention config.""" - def __init__(self, config: FrigateConfig, stop_event: MpEvent) -> None: + def __init__(self, config: FrigateConfig, stop_event: threading.Event) -> None: super().__init__(name="recording_cleanup") self.config = config self.stop_event = stop_event diff --git a/frigate/stats/emitter.py b/frigate/stats/emitter.py index 8a09ff51b..2fde8de4e 100644 --- a/frigate/stats/emitter.py +++ b/frigate/stats/emitter.py @@ -5,7 +5,6 @@ import json import logging import threading import time -from multiprocessing.synchronize import Event as MpEvent from typing import Optional from frigate.comms.inter_process import InterProcessRequestor @@ -25,7 +24,7 @@ class StatsEmitter(threading.Thread): self, config: FrigateConfig, stats_tracking: StatsTrackingTypes, - stop_event: MpEvent, + stop_event: threading.Event, ): super().__init__(name="frigate_stats_emitter") self.config = config diff --git a/frigate/storage.py b/frigate/storage.py index 2dbd07a51..225061f40 100644 --- a/frigate/storage.py +++ b/frigate/storage.py @@ -21,7 +21,7 @@ bandwidth_equation = Recordings.segment_size / ( class StorageMaintainer(threading.Thread): """Maintain frigates recording storage.""" - def __init__(self, config: FrigateConfig, stop_event) -> None: + def __init__(self, config: FrigateConfig, stop_event: threading.Event) -> None: super().__init__(name="storage_maintainer") self.config = config self.stop_event = stop_event diff --git a/frigate/timeline.py b/frigate/timeline.py index c3ef2ac5d..16391d6f6 100644 --- a/frigate/timeline.py +++ b/frigate/timeline.py @@ -4,7 +4,6 @@ import logging import queue import threading from multiprocessing import Queue -from multiprocessing.synchronize import Event as MpEvent from frigate.config import FrigateConfig from frigate.events.maintainer import EventTypeEnum @@ -21,7 +20,7 @@ class TimelineProcessor(threading.Thread): self, config: FrigateConfig, queue: Queue, - stop_event: MpEvent, + stop_event: threading.Event, ) -> None: super().__init__(name="timeline_processor") self.config = config diff --git a/frigate/watchdog.py b/frigate/watchdog.py index dad1f822e..0ce227d6d 100644 --- a/frigate/watchdog.py +++ b/frigate/watchdog.py @@ -1,7 +1,6 @@ import datetime import logging import threading -from multiprocessing.synchronize import Event as MpEvent from frigate.object_detection import ObjectDetectProcess from frigate.util.services import restart_frigate @@ -10,7 +9,9 @@ logger = logging.getLogger(__name__) class FrigateWatchdog(threading.Thread): - def __init__(self, detectors: dict[str, ObjectDetectProcess], stop_event: MpEvent): + def __init__( + self, detectors: dict[str, ObjectDetectProcess], stop_event: threading.Event + ): super().__init__(name="frigate_watchdog") self.detectors = detectors self.stop_event = stop_event