Replace __import__('datetime') antipattern in health_check task
This commit is contained in:
@@ -32,9 +32,10 @@ from app.utils.runtime_state import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
if TYPE_CHECKING: # pragma: no cover
|
if TYPE_CHECKING: # pragma: no cover
|
||||||
from app.config import Settings
|
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
|
|
||||||
|
from app.config import Settings
|
||||||
|
|
||||||
log: structlog.stdlib.BoundLogger = structlog.get_logger()
|
log: structlog.stdlib.BoundLogger = structlog.get_logger()
|
||||||
|
|
||||||
|
|
||||||
@@ -53,7 +54,7 @@ HEALTH_CHECK_INTERVAL: int = 30
|
|||||||
_ACTIVATION_CRASH_WINDOW: int = 60
|
_ACTIVATION_CRASH_WINDOW: int = 60
|
||||||
|
|
||||||
|
|
||||||
async def _run_probe_with_resources(settings: "Settings", runtime_state: RuntimeState) -> None:
|
async def _run_probe_with_resources(settings: Settings, runtime_state: RuntimeState) -> None:
|
||||||
"""Probe fail2ban and cache the result on the runtime state.
|
"""Probe fail2ban and cache the result on the runtime state.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -162,9 +163,7 @@ def register(app: FastAPI) -> None:
|
|||||||
id="health_check",
|
id="health_check",
|
||||||
replace_existing=True,
|
replace_existing=True,
|
||||||
# Fire immediately on startup too, so the UI isn't dark for 30 s.
|
# Fire immediately on startup too, so the UI isn't dark for 30 s.
|
||||||
next_run_time=__import__("datetime").datetime.now(
|
next_run_time=datetime.datetime.now(tz=datetime.UTC),
|
||||||
tz=__import__("datetime").timezone.utc
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
log.info(
|
log.info(
|
||||||
"health_check_scheduled",
|
"health_check_scheduled",
|
||||||
|
|||||||
Reference in New Issue
Block a user