Properly call super() in subclasses (#14124)

This commit is contained in:
gtsiam 2024-10-03 04:35:46 +03:00 committed by GitHub
parent 3c015bf822
commit 54900ae318
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 19 additions and 38 deletions

View File

@ -12,8 +12,7 @@ SOCKET_SUB = "ipc:///tmp/cache/proxy_sub"
class ZmqProxyRunner(threading.Thread): class ZmqProxyRunner(threading.Thread):
def __init__(self, context: zmq.Context[zmq.Socket]) -> None: def __init__(self, context: zmq.Context[zmq.Socket]) -> None:
threading.Thread.__init__(self) super().__init__(name="detection_proxy")
self.name = "detection_proxy"
self.context = context self.context = context
def run(self) -> None: def run(self) -> None:

View File

@ -26,9 +26,6 @@ DETECTOR_KEY = "tensorrt"
if TRT_SUPPORT: if TRT_SUPPORT:
class TrtLogger(trt.ILogger): class TrtLogger(trt.ILogger):
def __init__(self):
trt.ILogger.__init__(self)
def log(self, severity, msg): def log(self, severity, msg):
logger.log(self.getSeverity(severity), msg) logger.log(self.getSeverity(severity), msg)

View File

@ -23,8 +23,7 @@ class EventCleanupType(str, Enum):
class EventCleanup(threading.Thread): class EventCleanup(threading.Thread):
def __init__(self, config: FrigateConfig, stop_event: MpEvent): def __init__(self, config: FrigateConfig, stop_event: MpEvent):
threading.Thread.__init__(self) super().__init__(name="event_cleanup")
self.name = "event_cleanup"
self.config = config self.config = config
self.stop_event = stop_event self.stop_event = stop_event
self.camera_keys = list(self.config.cameras.keys()) self.camera_keys = list(self.config.cameras.keys())

View File

@ -54,8 +54,7 @@ class EventProcessor(threading.Thread):
timeline_queue: Queue, timeline_queue: Queue,
stop_event: MpEvent, stop_event: MpEvent,
): ):
threading.Thread.__init__(self) super().__init__(name="event_processor")
self.name = "event_processor"
self.config = config self.config = config
self.timeline_queue = timeline_queue self.timeline_queue = timeline_queue
self.events_in_process: Dict[str, Event] = {} self.events_in_process: Dict[str, Event] = {}

View File

@ -70,8 +70,7 @@ os.register_at_fork(after_in_child=reopen_std_streams)
class LogPipe(threading.Thread): class LogPipe(threading.Thread):
def __init__(self, log_name: str): def __init__(self, log_name: str):
"""Setup the object with a logger and start the thread""" """Setup the object with a logger and start the thread"""
threading.Thread.__init__(self) super().__init__(daemon=False)
self.daemon = False
self.logger = logging.getLogger(log_name) self.logger = logging.getLogger(log_name)
self.level = logging.ERROR self.level = logging.ERROR
self.deque: Deque[str] = deque(maxlen=100) self.deque: Deque[str] = deque(maxlen=100)

View File

@ -932,8 +932,7 @@ class TrackedObjectProcessor(threading.Thread):
ptz_autotracker_thread, ptz_autotracker_thread,
stop_event, stop_event,
): ):
threading.Thread.__init__(self) super().__init__(name="detected_frames_processor")
self.name = "detected_frames_processor"
self.config = config self.config = config
self.dispatcher = dispatcher self.dispatcher = dispatcher
self.tracked_objects_queue = tracked_objects_queue self.tracked_objects_queue = tracked_objects_queue

View File

@ -122,8 +122,7 @@ class FFMpegConverter(threading.Thread):
quality: int, quality: int,
birdseye_rtsp: bool = False, birdseye_rtsp: bool = False,
): ):
threading.Thread.__init__(self) super().__init__(name="birdseye_output_converter")
self.name = "birdseye_output_converter"
self.camera = "birdseye" self.camera = "birdseye"
self.input_queue = input_queue self.input_queue = input_queue
self.stop_event = stop_event self.stop_event = stop_event
@ -235,7 +234,7 @@ class BroadcastThread(threading.Thread):
websocket_server, websocket_server,
stop_event: mp.Event, stop_event: mp.Event,
): ):
super(BroadcastThread, self).__init__() super().__init__()
self.camera = camera self.camera = camera
self.converter = converter self.converter = converter
self.websocket_server = websocket_server self.websocket_server = websocket_server

View File

@ -24,8 +24,7 @@ class FFMpegConverter(threading.Thread):
out_height: int, out_height: int,
quality: int, quality: int,
): ):
threading.Thread.__init__(self) super().__init__(name=f"{camera}_output_converter")
self.name = f"{camera}_output_converter"
self.camera = camera self.camera = camera
self.input_queue = input_queue self.input_queue = input_queue
self.stop_event = stop_event self.stop_event = stop_event
@ -102,7 +101,7 @@ class BroadcastThread(threading.Thread):
websocket_server, websocket_server,
stop_event: mp.Event, stop_event: mp.Event,
): ):
super(BroadcastThread, self).__init__() super().__init__()
self.camera = camera self.camera = camera
self.converter = converter self.converter = converter
self.websocket_server = websocket_server self.websocket_server = websocket_server

View File

@ -66,8 +66,7 @@ class FFMpegConverter(threading.Thread):
frame_times: list[float], frame_times: list[float],
requestor: InterProcessRequestor, requestor: InterProcessRequestor,
): ):
threading.Thread.__init__(self) super().__init__(name=f"{config.name}_preview_converter")
self.name = f"{config.name}_preview_converter"
self.config = config self.config = config
self.frame_times = frame_times self.frame_times = frame_times
self.requestor = requestor self.requestor = requestor

View File

@ -149,8 +149,7 @@ class PtzAutoTrackerThread(threading.Thread):
dispatcher: Dispatcher, dispatcher: Dispatcher,
stop_event: MpEvent, stop_event: MpEvent,
) -> None: ) -> None:
threading.Thread.__init__(self) super().__init__(name="ptz_autotracker")
self.name = "ptz_autotracker"
self.ptz_autotracker = PtzAutoTracker( self.ptz_autotracker = PtzAutoTracker(
config, onvif, ptz_metrics, dispatcher, stop_event config, onvif, ptz_metrics, dispatcher, stop_event
) )

View File

@ -23,8 +23,7 @@ class RecordingCleanup(threading.Thread):
"""Cleanup existing recordings based on retention config.""" """Cleanup existing recordings based on retention config."""
def __init__(self, config: FrigateConfig, stop_event: MpEvent) -> None: def __init__(self, config: FrigateConfig, stop_event: MpEvent) -> None:
threading.Thread.__init__(self) super().__init__(name="recording_cleanup")
self.name = "recording_cleanup"
self.config = config self.config = config
self.stop_event = stop_event self.stop_event = stop_event

View File

@ -57,7 +57,7 @@ class RecordingExporter(threading.Thread):
end_time: int, end_time: int,
playback_factor: PlaybackFactorEnum, playback_factor: PlaybackFactorEnum,
) -> None: ) -> None:
threading.Thread.__init__(self) super().__init__()
self.config = config self.config = config
self.export_id = id self.export_id = id
self.camera = camera self.camera = camera

View File

@ -62,8 +62,7 @@ class SegmentInfo:
class RecordingMaintainer(threading.Thread): class RecordingMaintainer(threading.Thread):
def __init__(self, config: FrigateConfig, stop_event: MpEvent): def __init__(self, config: FrigateConfig, stop_event: MpEvent):
threading.Thread.__init__(self) super().__init__(name="recording_maintainer")
self.name = "recording_maintainer"
self.config = config self.config = config
# create communication for retained recordings # create communication for retained recordings

View File

@ -146,8 +146,7 @@ class ReviewSegmentMaintainer(threading.Thread):
"""Maintain review segments.""" """Maintain review segments."""
def __init__(self, config: FrigateConfig, stop_event: MpEvent): def __init__(self, config: FrigateConfig, stop_event: MpEvent):
threading.Thread.__init__(self) super().__init__(name="review_segment_maintainer")
self.name = "review_segment_maintainer"
self.config = config self.config = config
self.active_review_segments: dict[str, Optional[PendingReviewSegment]] = {} self.active_review_segments: dict[str, Optional[PendingReviewSegment]] = {}
self.frame_manager = SharedMemoryFrameManager() self.frame_manager = SharedMemoryFrameManager()

View File

@ -27,8 +27,7 @@ class StatsEmitter(threading.Thread):
stats_tracking: StatsTrackingTypes, stats_tracking: StatsTrackingTypes,
stop_event: MpEvent, stop_event: MpEvent,
): ):
threading.Thread.__init__(self) super().__init__(name="frigate_stats_emitter")
self.name = "frigate_stats_emitter"
self.config = config self.config = config
self.stats_tracking = stats_tracking self.stats_tracking = stats_tracking
self.stop_event = stop_event self.stop_event = stop_event

View File

@ -22,8 +22,7 @@ class StorageMaintainer(threading.Thread):
"""Maintain frigates recording storage.""" """Maintain frigates recording storage."""
def __init__(self, config: FrigateConfig, stop_event) -> None: def __init__(self, config: FrigateConfig, stop_event) -> None:
threading.Thread.__init__(self) super().__init__(name="storage_maintainer")
self.name = "storage_maintainer"
self.config = config self.config = config
self.stop_event = stop_event self.stop_event = stop_event
self.camera_storage_stats: dict[str, dict] = {} self.camera_storage_stats: dict[str, dict] = {}

View File

@ -23,8 +23,7 @@ class TimelineProcessor(threading.Thread):
queue: Queue, queue: Queue,
stop_event: MpEvent, stop_event: MpEvent,
) -> None: ) -> None:
threading.Thread.__init__(self) super().__init__(name="timeline_processor")
self.name = "timeline_processor"
self.config = config self.config = config
self.queue = queue self.queue = queue
self.stop_event = stop_event self.stop_event = stop_event

View File

@ -12,8 +12,7 @@ logger = logging.getLogger(__name__)
class FrigateWatchdog(threading.Thread): class FrigateWatchdog(threading.Thread):
def __init__(self, detectors: dict[str, ObjectDetectProcess], stop_event: MpEvent): def __init__(self, detectors: dict[str, ObjectDetectProcess], stop_event: MpEvent):
threading.Thread.__init__(self) super().__init__(name="frigate_watchdog")
self.name = "frigate_watchdog"
self.detectors = detectors self.detectors = detectors
self.stop_event = stop_event self.stop_event = stop_event