mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-08-07 11:21:11 +03:00
Require setting process priority for FrigateProcess (#19207)
This commit is contained in:
committed by
Blake Blackshear
parent
d071325ca7
commit
20104761e8
@@ -8,7 +8,12 @@ import numpy as np
|
||||
|
||||
from frigate.comms.embeddings_updater import EmbeddingsRequestEnum, EmbeddingsRequestor
|
||||
from frigate.comms.inter_process import InterProcessRequestor
|
||||
from frigate.const import CLIPS_DIR, MODEL_CACHE_DIR, UPDATE_MODEL_STATE
|
||||
from frigate.const import (
|
||||
CLIPS_DIR,
|
||||
MODEL_CACHE_DIR,
|
||||
UPDATE_MODEL_STATE,
|
||||
PROCESS_PRIORITY_LOW,
|
||||
)
|
||||
from frigate.log import redirect_output_to_logger
|
||||
from frigate.types import ModelStatusTypesEnum
|
||||
from frigate.util.process import FrigateProcess
|
||||
@@ -24,6 +29,7 @@ class ClassificationTrainingProcess(FrigateProcess):
|
||||
def __init__(self, model_name: str) -> None:
|
||||
super().__init__(
|
||||
stop_event=None,
|
||||
priority=PROCESS_PRIORITY_LOW,
|
||||
name=f"model_training:{model_name}",
|
||||
)
|
||||
self.model_name = model_name
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import faulthandler
|
||||
import logging
|
||||
import multiprocessing as mp
|
||||
import os
|
||||
import threading
|
||||
from logging.handlers import QueueHandler
|
||||
from multiprocessing.synchronize import Event as MpEvent
|
||||
@@ -16,6 +17,7 @@ class BaseProcess(mp.Process):
|
||||
def __init__(
|
||||
self,
|
||||
stop_event: MpEvent,
|
||||
priority: int,
|
||||
*,
|
||||
name: Optional[str] = None,
|
||||
target: Optional[Callable] = None,
|
||||
@@ -23,6 +25,7 @@ class BaseProcess(mp.Process):
|
||||
kwargs: dict = {},
|
||||
daemon: Optional[bool] = None,
|
||||
):
|
||||
self.priority = priority
|
||||
self.stop_event = stop_event
|
||||
super().__init__(
|
||||
name=name, target=target, args=args, kwargs=kwargs, daemon=daemon
|
||||
@@ -47,6 +50,7 @@ class FrigateProcess(BaseProcess):
|
||||
self.__log_queue = frigate.log.log_listener.queue
|
||||
|
||||
def pre_run_setup(self, logConfig: LoggerConfig | None = None) -> None:
|
||||
os.nice(self.priority)
|
||||
setproctitle(self.name)
|
||||
threading.current_thread().name = f"process:{self.name}"
|
||||
faulthandler.enable()
|
||||
|
||||
Reference in New Issue
Block a user