Nicholas Bumgarner commited on
Commit
fdff78d
·
1 Parent(s): e73f64f

Non-blocking boot wait: 0.5s sleep, only last 20 log lines

Browse files
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -149,25 +149,28 @@ def boot_phoenix():
149
  )
150
  _update_boot("start", f"Phoenix PID {_phoenix_proc.pid} — loading model (~40s)...")
151
 
152
- # Phase 4: Wait for model load (non-blocking, releases lock between checks)
153
- for i in range(90):
 
 
 
154
  if _phoenix_proc.poll() is not None:
155
  _update_boot("error", f"Phoenix exited early (code {_phoenix_proc.returncode})")
156
  return
157
  try:
158
  with open(STATE_LOG, 'r') as f:
159
- log = f.read()
 
160
  if "Chat Mode" in log:
161
- _update_boot("ready", "Phoenix ready — chat interface active!", ready=True)
162
  return
163
- # Check for model load completion
164
- if "Loaded" in log or "vocab" in log.lower():
165
- _update_boot("ready", f"Loading... ({i}s)", ready=False)
166
  except Exception:
167
  pass
168
- time.sleep(1)
169
 
170
- _update_boot("ready", "Phoenix likely loaded (timeout) — try chatting!", ready=True)
171
 
172
 
173
  def init_ring_buffers():
 
149
  )
150
  _update_boot("start", f"Phoenix PID {_phoenix_proc.pid} — loading model (~40s)...")
151
 
152
+ # Phase 4: Non-blocking wait loop
153
+ # The wait loop checks status periodically without blocking the event loop
154
+ # We use a short sleep + periodic log check
155
+ import json
156
+ for i in range(120):
157
  if _phoenix_proc.poll() is not None:
158
  _update_boot("error", f"Phoenix exited early (code {_phoenix_proc.returncode})")
159
  return
160
  try:
161
  with open(STATE_LOG, 'r') as f:
162
+ lines = f.readlines()[-20:] # only read last 20 lines
163
+ log = ''.join(lines)
164
  if "Chat Mode" in log:
165
+ _update_boot("ready", "Phoenix ready!", ready=True)
166
  return
167
+ if any("vocab" in l.lower() or "loaded" in l.lower() or "Loaded" in l for l in lines):
168
+ _update_boot("ready", f"Loading model... ({i}s)", ready=False)
 
169
  except Exception:
170
  pass
171
+ time.sleep(0.5)
172
 
173
+ _update_boot("ready", "Phoenix likely loaded — try chatting!", ready=True)
174
 
175
 
176
  def init_ring_buffers():