From 36e46087bc9a11ebe1503d0578938b44b9ff4585 Mon Sep 17 00:00:00 2001 From: Caleb Date: Sat, 28 Dec 2024 12:45:13 -0500 Subject: [PATCH] read /proc/meminfo in utils/system.py --- scale_build/utils/system.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scale_build/utils/system.py b/scale_build/utils/system.py index 0b4c9a98..b3e047ed 100644 --- a/scale_build/utils/system.py +++ b/scale_build/utils/system.py @@ -1,8 +1,12 @@ -import psutil +from functools import cache +REQUIRED_RAM_GB = 16 * (1024 ** 3) -REQUIRED_RAM = 16 # GB +__all__ = ("has_low_ram",) +@cache def has_low_ram(): - return psutil.virtual_memory().total < REQUIRED_RAM * 1024 * 1024 * 1024 + with open('/proc/meminfo') as f: + for line in filter(lambda x: 'MemTotal' in x, f): + return int(line.split()[1]) * 1024 < REQUIRED_RAM_GB