From af39439546773f5e186fa7c0482218c0e0b0e3fa Mon Sep 17 00:00:00 2001 From: George Tsiamasiotis Date: Wed, 2 Oct 2024 19:08:01 +0300 Subject: [PATCH] Properly call super() in subclasses --- frigate/comms/zmq_proxy.py | 3 +-- frigate/detectors/plugins/tensorrt.py | 3 --- frigate/events/cleanup.py | 3 +-- frigate/events/maintainer.py | 3 +-- frigate/log.py | 3 +-- frigate/object_processing.py | 3 +-- frigate/output/birdseye.py | 5 ++--- frigate/output/camera.py | 5 ++--- frigate/output/preview.py | 3 +-- frigate/ptz/autotrack.py | 3 +-- frigate/record/cleanup.py | 3 +-- frigate/record/export.py | 2 +- frigate/stats/emitter.py | 3 +-- frigate/storage.py | 3 +-- frigate/timeline.py | 3 +-- frigate/watchdog.py | 3 +-- 16 files changed, 17 insertions(+), 34 deletions(-) diff --git a/frigate/comms/zmq_proxy.py b/frigate/comms/zmq_proxy.py index bbe660160..1661cfcc5 100644 --- a/frigate/comms/zmq_proxy.py +++ b/frigate/comms/zmq_proxy.py @@ -12,8 +12,7 @@ SOCKET_SUB = "ipc:///tmp/cache/proxy_sub" class ZmqProxyRunner(threading.Thread): def __init__(self, context: zmq.Context[zmq.Socket]) -> None: - threading.Thread.__init__(self) - self.name = "detection_proxy" + super().__init__(name="detection_proxy") self.context = context def run(self) -> None: diff --git a/frigate/detectors/plugins/tensorrt.py b/frigate/detectors/plugins/tensorrt.py index bb3c737ad..37936e191 100644 --- a/frigate/detectors/plugins/tensorrt.py +++ b/frigate/detectors/plugins/tensorrt.py @@ -26,9 +26,6 @@ DETECTOR_KEY = "tensorrt" if TRT_SUPPORT: class TrtLogger(trt.ILogger): - def __init__(self): - trt.ILogger.__init__(self) - def log(self, severity, msg): logger.log(self.getSeverity(severity), msg) diff --git a/frigate/events/cleanup.py b/frigate/events/cleanup.py index 35edf4195..740449526 100644 --- a/frigate/events/cleanup.py +++ b/frigate/events/cleanup.py @@ -23,8 +23,7 @@ class EventCleanupType(str, Enum): class EventCleanup(threading.Thread): def __init__(self, config: FrigateConfig, stop_event: MpEvent): - threading.Thread.__init__(self) - self.name = "event_cleanup" + super().__init__(name="event_cleanup") self.config = config self.stop_event = stop_event self.camera_keys = list(self.config.cameras.keys()) diff --git a/frigate/events/maintainer.py b/frigate/events/maintainer.py index eca109c3e..7895c770c 100644 --- a/frigate/events/maintainer.py +++ b/frigate/events/maintainer.py @@ -54,8 +54,7 @@ class EventProcessor(threading.Thread): timeline_queue: Queue, stop_event: MpEvent, ): - threading.Thread.__init__(self) - self.name = "event_processor" + super().__init__(name="event_processor") self.config = config self.timeline_queue = timeline_queue self.events_in_process: Dict[str, Event] = {} diff --git a/frigate/log.py b/frigate/log.py index 23bf53c49..229b4d67e 100644 --- a/frigate/log.py +++ b/frigate/log.py @@ -56,8 +56,7 @@ def _stop_logging() -> None: class LogPipe(threading.Thread): def __init__(self, log_name: str): """Setup the object with a logger and start the thread""" - threading.Thread.__init__(self) - self.daemon = False + super().__init__(daemon=False) self.logger = logging.getLogger(log_name) self.level = logging.ERROR self.deque: Deque[str] = deque(maxlen=100) diff --git a/frigate/object_processing.py b/frigate/object_processing.py index 19cb5ae2b..32f5bea97 100644 --- a/frigate/object_processing.py +++ b/frigate/object_processing.py @@ -921,8 +921,7 @@ class TrackedObjectProcessor(threading.Thread): ptz_autotracker_thread, stop_event, ): - threading.Thread.__init__(self) - self.name = "detected_frames_processor" + super().__init__(name="detected_frames_processor") self.config = config self.dispatcher = dispatcher self.tracked_objects_queue = tracked_objects_queue diff --git a/frigate/output/birdseye.py b/frigate/output/birdseye.py index 00e7c7ad1..c187c77ea 100644 --- a/frigate/output/birdseye.py +++ b/frigate/output/birdseye.py @@ -122,8 +122,7 @@ class FFMpegConverter(threading.Thread): quality: int, birdseye_rtsp: bool = False, ): - threading.Thread.__init__(self) - self.name = "birdseye_output_converter" + super().__init__(name="birdseye_output_converter") self.camera = "birdseye" self.input_queue = input_queue self.stop_event = stop_event @@ -235,7 +234,7 @@ class BroadcastThread(threading.Thread): websocket_server, stop_event: mp.Event, ): - super(BroadcastThread, self).__init__() + super().__init__() self.camera = camera self.converter = converter self.websocket_server = websocket_server diff --git a/frigate/output/camera.py b/frigate/output/camera.py index 317d7902e..2311ec659 100644 --- a/frigate/output/camera.py +++ b/frigate/output/camera.py @@ -24,8 +24,7 @@ class FFMpegConverter(threading.Thread): out_height: int, quality: int, ): - threading.Thread.__init__(self) - self.name = f"{camera}_output_converter" + super().__init__(name=f"{camera}_output_converter") self.camera = camera self.input_queue = input_queue self.stop_event = stop_event @@ -102,7 +101,7 @@ class BroadcastThread(threading.Thread): websocket_server, stop_event: mp.Event, ): - super(BroadcastThread, self).__init__() + super().__init__() self.camera = camera self.converter = converter self.websocket_server = websocket_server diff --git a/frigate/output/preview.py b/frigate/output/preview.py index 5b5dd4afa..a8915f688 100644 --- a/frigate/output/preview.py +++ b/frigate/output/preview.py @@ -66,8 +66,7 @@ class FFMpegConverter(threading.Thread): frame_times: list[float], requestor: InterProcessRequestor, ): - threading.Thread.__init__(self) - self.name = f"{config.name}_preview_converter" + super().__init__(name=f"{config.name}_preview_converter") self.config = config self.frame_times = frame_times self.requestor = requestor diff --git a/frigate/ptz/autotrack.py b/frigate/ptz/autotrack.py index 05912a850..9366dae56 100644 --- a/frigate/ptz/autotrack.py +++ b/frigate/ptz/autotrack.py @@ -149,8 +149,7 @@ class PtzAutoTrackerThread(threading.Thread): dispatcher: Dispatcher, stop_event: MpEvent, ) -> None: - threading.Thread.__init__(self) - self.name = "ptz_autotracker" + super().__init__(name="ptz_autotracker") self.ptz_autotracker = PtzAutoTracker( config, onvif, ptz_metrics, dispatcher, stop_event ) diff --git a/frigate/record/cleanup.py b/frigate/record/cleanup.py index 615b6bdbd..b70a23b45 100644 --- a/frigate/record/cleanup.py +++ b/frigate/record/cleanup.py @@ -23,8 +23,7 @@ class RecordingCleanup(threading.Thread): """Cleanup existing recordings based on retention config.""" def __init__(self, config: FrigateConfig, stop_event: MpEvent) -> None: - threading.Thread.__init__(self) - self.name = "recording_cleanup" + super().__init__(name="recording_cleanup") self.config = config self.stop_event = stop_event diff --git a/frigate/record/export.py b/frigate/record/export.py index 7d38e60f1..5e41fb83e 100644 --- a/frigate/record/export.py +++ b/frigate/record/export.py @@ -56,7 +56,7 @@ class RecordingExporter(threading.Thread): end_time: int, playback_factor: PlaybackFactorEnum, ) -> None: - threading.Thread.__init__(self) + super().__init__() self.config = config self.camera = camera self.user_provided_name = name diff --git a/frigate/stats/emitter.py b/frigate/stats/emitter.py index 1683935e2..8a09ff51b 100644 --- a/frigate/stats/emitter.py +++ b/frigate/stats/emitter.py @@ -27,8 +27,7 @@ class StatsEmitter(threading.Thread): stats_tracking: StatsTrackingTypes, stop_event: MpEvent, ): - threading.Thread.__init__(self) - self.name = "frigate_stats_emitter" + super().__init__(name="frigate_stats_emitter") self.config = config self.stats_tracking = stats_tracking self.stop_event = stop_event diff --git a/frigate/storage.py b/frigate/storage.py index 029c5c388..2dbd07a51 100644 --- a/frigate/storage.py +++ b/frigate/storage.py @@ -22,8 +22,7 @@ class StorageMaintainer(threading.Thread): """Maintain frigates recording storage.""" def __init__(self, config: FrigateConfig, stop_event) -> None: - threading.Thread.__init__(self) - self.name = "storage_maintainer" + super().__init__(name="storage_maintainer") self.config = config self.stop_event = stop_event self.camera_storage_stats: dict[str, dict] = {} diff --git a/frigate/timeline.py b/frigate/timeline.py index e60638284..c3ef2ac5d 100644 --- a/frigate/timeline.py +++ b/frigate/timeline.py @@ -23,8 +23,7 @@ class TimelineProcessor(threading.Thread): queue: Queue, stop_event: MpEvent, ) -> None: - threading.Thread.__init__(self) - self.name = "timeline_processor" + super().__init__(name="timeline_processor") self.config = config self.queue = queue self.stop_event = stop_event diff --git a/frigate/watchdog.py b/frigate/watchdog.py index dae687390..dad1f822e 100644 --- a/frigate/watchdog.py +++ b/frigate/watchdog.py @@ -11,8 +11,7 @@ logger = logging.getLogger(__name__) class FrigateWatchdog(threading.Thread): def __init__(self, detectors: dict[str, ObjectDetectProcess], stop_event: MpEvent): - threading.Thread.__init__(self) - self.name = "frigate_watchdog" + super().__init__(name="frigate_watchdog") self.detectors = detectors self.stop_event = stop_event