Nicholas Bumgarner commited on
Commit
3e5b14e
·
1 Parent(s): adcbc7e

Fix lock contention: get_boot_status reads without lock, phox_chat checks minimal

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -273,8 +273,11 @@ def stop_phoenix():
273
 
274
  def get_boot_status():
275
  """Return current boot status for the UI."""
276
- with _state_lock:
 
277
  return dict(_boot_status)
 
 
278
 
279
 
280
  def phox_chat(message, history):
@@ -283,8 +286,9 @@ def phox_chat(message, history):
283
  return "Engine not initialized. Please wait for startup."
284
 
285
  with _state_lock:
286
- if _phoenix_proc is None or _phoenix_proc.poll() is not None:
287
- return "Phoenix is not running. Please click 'Start Engine' first."
 
288
 
289
  if _tokenizer is None:
290
  return "Tokenizer not loaded."
 
273
 
274
  def get_boot_status():
275
  """Return current boot status for the UI."""
276
+ # Read without lock to avoid contention with boot_phoenix thread
277
+ try:
278
  return dict(_boot_status)
279
+ except Exception:
280
+ return {"ready": False, "phase": "error", "message": "Status unavailable"}
281
 
282
 
283
  def phox_chat(message, history):
 
286
  return "Engine not initialized. Please wait for startup."
287
 
288
  with _state_lock:
289
+ phoenix_running = _phoenix_proc is not None and _phoenix_proc.poll() is None
290
+ if not phoenix_running:
291
+ return "Phoenix is not running. Please click 'Start Engine' first."
292
 
293
  if _tokenizer is None:
294
  return "Tokenizer not loaded."