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):
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:

View File

@ -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)

View File

@ -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())

View File

@ -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] = {}

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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()

View File

@ -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

View File

@ -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] = {}

View File

@ -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

View File

@ -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