From f17ff1e98a47ea150c35d5a99240aac8a7c1f034 Mon Sep 17 00:00:00 2001 From: VS Date: Fri, 25 Sep 2026 12:21:47 +0200 Subject: [PATCH] Fix --- app.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index 6cd63dc..4746bbe 100644 --- a/app.py +++ b/app.py @@ -10,7 +10,8 @@ from retinaface import RetinaFace treashold = float(os.getenv('FACE_TRASHOLD', '0.9')) sever = os.getenv('API_ROOT', 'localhost:8000') -disk_treashold = os.getenv('DISK_FREE_TRASHOLD', 10) +disk_treashold = float(os.getenv('DISK_FREE_TRASHOLD', '10.0')) +disk_treashold_gb = float(os.getenv('DISK_FREE_TRASHOLD_GB', '20.0')) root_api_url = 'http://{}/local'.format(sever) base_path = '/app/data/' @@ -18,6 +19,7 @@ base_path = '/app/data/' print("API_ROOT: " + str(root_api_url), flush=True) print("FACE_TRASHOLD: " + str(treashold), flush=True) print("DISK_FREE_TRASHOLD: " + str(disk_treashold), flush=True) +print("DISK_FREE_TRASHOLD_GB: " + str(disk_treashold_gb), flush=True) try: while True: @@ -26,10 +28,14 @@ try: #Chesk if there is enought free space at destination path while True: total, used, free = shutil.disk_usage(base_path) - if (free // (2**30)) > ((total / 100) * disk_treashold) // (2**30): + free_gb = free / (2**30) + below_percent = free < (total / 100) * disk_treashold + not_above_gb = free_gb <= disk_treashold_gb + # Not enough space only if free space is below the % threshold AND not above the GB threshold + if not (below_percent and not_above_gb): break - data = {"trace": "not enought free space at destination" + str(base_path) + " trashold is: " + str(disk_treashold) + "%"} + data = {"trace": "not enought free space at destination" + str(base_path) + " trashold is: " + str(disk_treashold) + "% and " + str(disk_treashold_gb) + " GB"} response = requests.post('{}/log'.format(root_api_url), json=data) print("sleep", flush=True)