From 2e1f551281d56928f6ca57fd02af6b6ebecce8c1 Mon Sep 17 00:00:00 2001 From: Long Chen Date: Mon, 11 Nov 2024 13:42:21 +0800 Subject: [PATCH] chore: fix type check for worker and cpu monitor --- livekit-agents/livekit/agents/utils/hw/cpu.py | 2 +- livekit-agents/livekit/agents/worker.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/livekit-agents/livekit/agents/utils/hw/cpu.py b/livekit-agents/livekit/agents/utils/hw/cpu.py index faf3d9ec13..f71d3ef5bb 100644 --- a/livekit-agents/livekit/agents/utils/hw/cpu.py +++ b/livekit-agents/livekit/agents/utils/hw/cpu.py @@ -21,7 +21,7 @@ def cpu_percent(self, interval: float = 0.5) -> float: class DefaultCPUMonitor(CPUMonitor): def cpu_count(self) -> float: - return psutil.cpu_count() + return psutil.cpu_count() or 0 def cpu_percent(self, interval: float = 0.5) -> float: return psutil.cpu_percent(interval) / 100.0 diff --git a/livekit-agents/livekit/agents/worker.py b/livekit-agents/livekit/agents/worker.py index 635a6f280b..7b22a4a25b 100644 --- a/livekit-agents/livekit/agents/worker.py +++ b/livekit-agents/livekit/agents/worker.py @@ -569,6 +569,9 @@ async def _recv_task(): await utils.aio.gracefully_cancel(*tasks) async def _reload_jobs(self, jobs: list[RunningJobInfo]) -> None: + if not self._opts.api_secret: + raise RuntimeError("api_secret is required to reload jobs") + for aj in jobs: logger.log( DEV_LEVEL,