From 54900ae3180c0685db1ca0437dc3aa9e60539fde Mon Sep 17 00:00:00 2001 From: gtsiam Date: Thu, 3 Oct 2024 04:35:46 +0300 Subject: [PATCH] Properly call super() in subclasses (#14124) --- 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/record/maintainer.py | 3 +-- frigate/review/maintainer.py | 3 +-- frigate/stats/emitter.py | 3 +-- frigate/storage.py | 3 +-- frigate/timeline.py | 3 +-- frigate/watchdog.py | 3 +-- 18 files changed, 19 insertions(+), 38 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 0113047f2..b17bd5d35 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 a657fbb7d..079fc6107 100644 --- a/frigate/log.py +++ b/frigate/log.py @@ -70,8 +70,7 @@ os.register_at_fork(after_in_child=reopen_std_streams) 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 55f494d55..15874ca4e 100644 --- a/frigate/object_processing.py +++ b/frigate/object_processing.py @@ -932,8 +932,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 d28166a7b..fd9933bcb 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 cbdb53014..395da79ea 100644 --- a/frigate/record/export.py +++ b/frigate/record/export.py @@ -57,7 +57,7 @@ class RecordingExporter(threading.Thread): end_time: int, playback_factor: PlaybackFactorEnum, ) -> None: - threading.Thread.__init__(self) + super().__init__() self.config = config self.export_id = id self.camera = camera diff --git a/frigate/record/maintainer.py b/frigate/record/maintainer.py index bbc20d612..f43d1424f 100644 --- a/frigate/record/maintainer.py +++ b/frigate/record/maintainer.py @@ -62,8 +62,7 @@ class SegmentInfo: class RecordingMaintainer(threading.Thread): def __init__(self, config: FrigateConfig, stop_event: MpEvent): - threading.Thread.__init__(self) - self.name = "recording_maintainer" + super().__init__(name="recording_maintainer") self.config = config # create communication for retained recordings diff --git a/frigate/review/maintainer.py b/frigate/review/maintainer.py index b92fac99d..3b5980a85 100644 --- a/frigate/review/maintainer.py +++ b/frigate/review/maintainer.py @@ -146,8 +146,7 @@ class ReviewSegmentMaintainer(threading.Thread): """Maintain review segments.""" def __init__(self, config: FrigateConfig, stop_event: MpEvent): - threading.Thread.__init__(self) - self.name = "review_segment_maintainer" + super().__init__(name="review_segment_maintainer") self.config = config self.active_review_segments: dict[str, Optional[PendingReviewSegment]] = {} self.frame_manager = SharedMemoryFrameManager() 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 4a7ad7329..8055ccddc 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 c6d55d18c..d7cdec796 100644 --- a/frigate/watchdog.py +++ b/frigate/watchdog.py @@ -12,8 +12,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