Neon-tech commited on
Commit
e514642
Β·
verified Β·
1 Parent(s): b78a519

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -55,9 +55,17 @@ def load_state():
55
  print("Starting fresh")
56
  return state
57
 
58
- def save_state(state):
59
- with open(STATE_FILE, "w") as f:
60
- json.dump(state, f, indent=2)
 
 
 
 
 
 
 
 
61
 
62
  # ── Shard buffers β€” global per language, persist across parquets ─────────────
63
  buffers = {}
 
55
  print("Starting fresh")
56
  return state
57
 
58
+ def save_state(state, retries=3, delay=5):
59
+ for attempt in range(retries):
60
+ try:
61
+ with open(STATE_FILE, "w") as f:
62
+ json.dump(state, f, indent=2)
63
+ return
64
+ except OSError as e:
65
+ print(f" ⚠ State save attempt {attempt + 1} failed: {e}")
66
+ if attempt < retries - 1:
67
+ time.sleep(delay)
68
+ print(" βœ— State save failed after all retries β€” continuing")
69
 
70
  # ── Shard buffers β€” global per language, persist across parquets ─────────────
71
  buffers = {}