This commit is contained in:
2025-10-31 11:22:19 -07:00
parent 8c31125d5b
commit 982c101259

23
app.py
View File

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