Cleanup port defining

This commit is contained in:
Nicolas Mowen 2024-02-14 07:34:41 -07:00
parent c1bd6bdc51
commit 5f7ca2b124
5 changed files with 9 additions and 24 deletions

View File

@ -56,7 +56,8 @@ class InterProcessCommunicator(Communicator):
class InterProcessRequestor:
"""Simplifies sending data to InterProcessCommunicator and getting a reply."""
def __init__(self, port: int) -> None:
def __init__(self) -> None:
port = os.environ.get("INTER_PROCESS_COMM_PORT") or PORT_INTER_PROCESS_COMM
self.context = zmq.Context()
self.socket = self.context.socket(zmq.REQ)
self.socket.connect(f"tcp://127.0.0.1:{port}")

View File

@ -3,7 +3,6 @@
import datetime
import logging
import multiprocessing as mp
import os
import signal
import threading
import time
@ -23,7 +22,6 @@ from frigate.const import (
AUDIO_MIN_CONFIDENCE,
AUDIO_SAMPLE_RATE,
FRIGATE_LOCALHOST,
PORT_INTER_PROCESS_COMM,
)
from frigate.ffmpeg_presets import parse_preset_input
from frigate.log import LogPipe
@ -191,11 +189,8 @@ class AudioEventMaintainer(threading.Thread):
self.logpipe = LogPipe(f"ffmpeg.{self.config.name}.audio")
self.audio_listener = None
# create communication for finished previews
INTER_PROCESS_COMM_PORT = (
os.environ.get("INTER_PROCESS_COMM_PORT") or PORT_INTER_PROCESS_COMM
)
self.requestor = InterProcessRequestor(INTER_PROCESS_COMM_PORT)
# create communication for audio detections
self.requestor = InterProcessRequestor()
def detect_audio(self, audio) -> None:
if not self.feature_metrics[self.config.name]["audio_enabled"].value:

View File

@ -13,7 +13,7 @@ import numpy as np
from frigate.comms.inter_process import InterProcessRequestor
from frigate.config import CameraConfig, RecordQualityEnum
from frigate.const import CACHE_DIR, CLIPS_DIR, INSERT_PREVIEW, PORT_INTER_PROCESS_COMM
from frigate.const import CACHE_DIR, CLIPS_DIR, INSERT_PREVIEW
from frigate.ffmpeg_presets import (
FPS_VFR_PARAM,
EncodeTypeEnum,
@ -137,10 +137,7 @@ class PreviewRecorder:
)
# create communication for finished previews
INTER_PROCESS_COMM_PORT = (
os.environ.get("INTER_PROCESS_COMM_PORT") or PORT_INTER_PROCESS_COMM
)
self.requestor = InterProcessRequestor(INTER_PROCESS_COMM_PORT)
self.requestor = InterProcessRequestor()
y, u1, u2, v1, v2 = get_yuv_crop(
self.config.frame_shape_yuv,

View File

@ -25,7 +25,6 @@ from frigate.const import (
INSERT_MANY_RECORDINGS,
MAX_SEGMENT_DURATION,
MAX_SEGMENTS_IN_CACHE,
PORT_INTER_PROCESS_COMM,
RECORD_DIR,
)
from frigate.models import Event, Recordings
@ -71,10 +70,7 @@ class RecordingMaintainer(threading.Thread):
self.config = config
# create communication for retained recordings
INTER_PROCESS_COMM_PORT = (
os.environ.get("INTER_PROCESS_COMM_PORT") or PORT_INTER_PROCESS_COMM
)
self.requestor = InterProcessRequestor(INTER_PROCESS_COMM_PORT)
self.requestor = InterProcessRequestor()
self.object_recordings_info_queue = object_recordings_info_queue
self.audio_recordings_info_queue = audio_recordings_info_queue

View File

@ -18,7 +18,6 @@ from frigate.const import (
ATTRIBUTE_LABEL_MAP,
CACHE_DIR,
CACHE_SEGMENT_FORMAT,
PORT_INTER_PROCESS_COMM,
REQUEST_REGION_GRID,
)
from frigate.log import LogPipe
@ -433,11 +432,8 @@ def track_camera(
frame_manager = SharedMemoryFrameManager()
# create communication for finished previews
INTER_PROCESS_COMM_PORT = (
os.environ.get("INTER_PROCESS_COMM_PORT") or PORT_INTER_PROCESS_COMM
)
requestor = InterProcessRequestor(INTER_PROCESS_COMM_PORT)
# create communication for region grid updates
requestor = InterProcessRequestor()
process_frames(
name,