minor last fix-ups

This commit is contained in:
Jörn-Michael Miehe 2023-09-02 14:33:38 +00:00
parent 4f67c6158d
commit 4205b04b05
2 changed files with 12 additions and 4 deletions

View file

@ -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,

View file

@ -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