refactor: one load threshold for every probe

This commit is contained in:
Abdessamad Derraz committed 2026-11-21 19:50:33 +01:00
1 parent 91e385598e
commit eddb26f104
5 files changed
+32 -8

No files matched your search

+6 -1
View File
@@ -1587,8 +1587,13 @@ def probe(args: argparse.Namespace) -> int:
return _probe(args)
def default_max_load(cpus: int | None = None) -> float:
"""The load above which a run records nothing without --max-load: a quarter of the CPUs."""
return (cpus if cpus is not None else os.cpu_count() or 1) / 4
def _probe(args: argparse.Namespace) -> int:
max_load = args.max_load if args.max_load is not None else (os.cpu_count() or 1) / 4
max_load = args.max_load if args.max_load is not None else default_max_load()
load_before = load_average()
if args.record and load_before and load_before[0] > max_load:
print(f"ERROR: load average {load_before[0]} exceeds {max_load}: the machine is busy, "