abinazebinoy commited on
Commit
05ed738
·
1 Parent(s): c20cdf7

fix(B-01): define _stats_lock -- NameError crashed GET /stats on every call

Browse files

api/main.py used 'with _stats_lock:' at line 146 but the lock object was
never created and threading was never imported. Every call to GET /stats
raised NameError: name '_stats_lock' is not defined, completely breaking
the stats endpoint and the homepage statistics panel.

Files changed (1) hide show
  1. api/main.py +2 -0
api/main.py CHANGED
@@ -131,6 +131,8 @@ def health_check():
131
  _stats_cache = None
132
  _stats_cached_at = 0.0
133
  _STATS_TTL = 60.0
 
 
134
 
135
 
136
  @app.get("/stats", response_model=StatsResponse)
 
131
  _stats_cache = None
132
  _stats_cached_at = 0.0
133
  _STATS_TTL = 60.0
134
+ import threading as _threading # B-01 FIX: was missing entirely
135
+ _stats_lock = _threading.Lock() # B-01 FIX: NameError on every GET /stats
136
 
137
 
138
  @app.get("/stats", response_model=StatsResponse)