farm/chr/shim refresh + verified economics 04.11.26 (5000 credits, autoreg 2/2)

This commit is contained in:
reform
2026-11-04 13:16:39 +03:00
parent 871839d07b
commit 7ea965153f
4 changed files with 131 additions and 34 deletions
+17 -9
View File
@@ -69,18 +69,26 @@ def reload_if_changed():
def alive_keys():
"""[RR 1101] round-robin over live keys.
CAMB throttles a single account when many requests hit it back to back, and one
slow key used to add its full timeout to every call. Start each request at a
different offset so load spreads across the pool.
"""
global _idx
now = time.time()
out = []
for k in _keys:
if k in _dead:
continue
if _cool.get(k, 0) > now:
continue
out.append(k)
return out or [k for k in _keys if k not in _dead]
live = [k for k in _keys if k not in _dead and _cool.get(k, 0) <= now]
if not live:
live = [k for k in _keys if k not in _dead]
if not live:
return []
with _lock:
start = _idx % len(live)
_idx += 1
return live[start:] + live[:start]
def call_upstream(key, body, timeout=180):
def call_upstream(key, body, timeout=75):
req = urllib.request.Request(
UPSTREAM,
data=json.dumps(body).encode(),