From 4205b04b0517f378f70d786b7dd8246f75e20d65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Sat, 2 Sep 2023 14:33:38 +0000 Subject: [PATCH] minor last fix-ups --- kiwi_simple_metrics/main.py | 10 ++++++---- kiwi_simple_metrics/settings/metric.py | 6 ++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/kiwi_simple_metrics/main.py b/kiwi_simple_metrics/main.py index 2c0dba5..7d1b3f4 100644 --- a/kiwi_simple_metrics/main.py +++ b/kiwi_simple_metrics/main.py @@ -44,15 +44,17 @@ def run_metrics( async def async_main_loop() -> None: loop = asyncio.get_running_loop() - while True: - with concurrent.futures.ThreadPoolExecutor( - max_workers=SETTINGS.threads, - ) as pool: + with concurrent.futures.ThreadPoolExecutor( + max_workers=SETTINGS.threads, + ) as pool: + while True: + # start interval and metrics at the same time await asyncio.gather( asyncio.sleep(SETTINGS.interval), loop.run_in_executor( None, run_metrics, pool, + # metrics are reported in this order metrics.cpu, metrics.memory, metrics.disk, diff --git a/kiwi_simple_metrics/settings/metric.py b/kiwi_simple_metrics/settings/metric.py index 49e1b23..d1b5b68 100644 --- a/kiwi_simple_metrics/settings/metric.py +++ b/kiwi_simple_metrics/settings/metric.py @@ -93,3 +93,9 @@ class ExternalMS(MetricSettings): # wait at most this many seconds for each executable timeout: int = 60 + + @field_validator("count", mode="after") + @classmethod + def force_none(cls, _) -> int | None: + """Don't accept a `count` value for the external metric!""" + return None