caches
This commit is contained in:
23
app.py
23
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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user