From 982c1012596d7d4156d5962a58fcf541bdf637f5 Mon Sep 17 00:00:00 2001 From: Bryce Date: Fri, 31 Oct 2025 11:22:19 -0700 Subject: [PATCH] caches --- app.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 1b55fc4..50186fc 100644 --- a/app.py +++ b/app.py @@ -106,9 +106,30 @@ def fetch_all_projects(): project_cache.set_projects(detailed_rows) return detailed_rows +import time +import threading + def async_cache_projects(): from threading import Thread - thread = Thread(target=fetch_all_projects, args=()) + + def cache_loop(): + while True: + try: + # Check if cache is already being updated to avoid concurrent updates + if not project_cache.is_updating(): + project_cache.set_updating(True) + fetch_all_projects() + project_cache.set_updating(False) + else: + print("Cache update already in progress, skipping this cycle") + except Exception as e: + print(f"Error in cache loop: {e}") + project_cache.set_updating(False) + + # Wait for 15 minutes before next update + time.sleep(15 * 60) # 15 minutes in seconds + + thread = Thread(target=cache_loop, args=()) thread.daemon = True thread.start()