mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-10-15 19:22:52 +03:00
Increase ruff coverage (#23644)
CI / AMD64 Build (push) Waiting to run
CI / ARM Build (push) Waiting to run
CI / AMD64 Extra Build (push) Blocked by required conditions
CI / ARM Extra Build (push) Blocked by required conditions
CI / Synaptics Build (push) Blocked by required conditions
CI / Assemble and push default build (push) Blocked by required conditions
CI / Jetson Jetpack 6 (push) Waiting to run
CI / AMD64 Build (push) Waiting to run
CI / ARM Build (push) Waiting to run
CI / AMD64 Extra Build (push) Blocked by required conditions
CI / ARM Extra Build (push) Blocked by required conditions
CI / Synaptics Build (push) Blocked by required conditions
CI / Assemble and push default build (push) Blocked by required conditions
CI / Jetson Jetpack 6 (push) Waiting to run
* Pin ruff * Add python upgrade fixes This enables python upgrade checks in ruff to look for deprecated types and patterns. This namely fixes: - usage of deprecated `Typing` which is now built in - some specific exceptions which are caught and have new aliases Some specific UP checks were also ignored as they are stylistic / unimportant and likely to cause bugs * Remove async blocking calls Use asyncio.to_thread on two remaining blocking calls to fix hanging event thread loop. Enable this specific rule to block it in the future. * Use proper logging mechanism * Correctly format logs * Raise with context When raising an exception include the from context to improve debugging * Cleanup
This commit is contained in:
@@ -9,7 +9,6 @@ from abc import ABC, abstractmethod
|
||||
from asyncio.exceptions import TimeoutError
|
||||
from logging.handlers import QueueHandler
|
||||
from types import FrameType
|
||||
from typing import Optional
|
||||
|
||||
import frigate.log
|
||||
|
||||
@@ -22,13 +21,13 @@ DEFAULT_STOP_TIMEOUT = 10 # seconds
|
||||
class BaseServiceProcess(Service, ABC):
|
||||
"""A Service the manages a multiprocessing.Process."""
|
||||
|
||||
_process: Optional[mp.Process]
|
||||
_process: mp.Process | None
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
name: Optional[str] = None,
|
||||
manager: Optional[ServiceManager] = None,
|
||||
name: str | None = None,
|
||||
manager: ServiceManager | None = None,
|
||||
) -> None:
|
||||
super().__init__(name=name, manager=manager)
|
||||
|
||||
@@ -55,7 +54,7 @@ class BaseServiceProcess(Service, ABC):
|
||||
self,
|
||||
*,
|
||||
force: bool = False,
|
||||
timeout: Optional[float] = None,
|
||||
timeout: float | None = None,
|
||||
) -> None:
|
||||
if timeout is None:
|
||||
timeout = DEFAULT_STOP_TIMEOUT
|
||||
@@ -85,7 +84,7 @@ class BaseServiceProcess(Service, ABC):
|
||||
self.manager.logger.info(f"{self.name} stopped")
|
||||
|
||||
@property
|
||||
def pid(self) -> Optional[int]:
|
||||
def pid(self) -> int | None:
|
||||
return self._process.pid if self._process else None
|
||||
|
||||
def _run(self) -> None:
|
||||
@@ -143,7 +142,7 @@ class ServiceProcess(BaseServiceProcess):
|
||||
|
||||
faulthandler.enable()
|
||||
|
||||
def receiveSignal(signalNumber: int, frame: Optional[FrameType]) -> None:
|
||||
def receiveSignal(signalNumber: int, frame: FrameType | None) -> None:
|
||||
# Get the stop_event through the dict to bypass lazy initialization.
|
||||
stop_event = self.__dict__.get("stop_event")
|
||||
if stop_event is not None:
|
||||
|
||||
Reference in New Issue
Block a user