Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

serve: a request the engine refuses with ERR answers at once, not after a 300 s wait for a DONE (#1059)

Niko1221ef6c18a14a7f
diff --git a/serve/server.py b/serve/server.py
index d6b1fc37e..b1d7a2471 100644
--- a/serve/server.py
+++ b/serve/server.py
@@ -668,6 +668,7 @@ class StrataEngine:
self.ctl_epoch = 0 # how often the control lines were taken
self.ctl = threading.Lock() # one admission or solo request on the control lines at a time
self.gen = self.__dict__.get("gen", 0) + 1 # which engine process this is (a request notes its own)
+ self._ctl_erred = False # #1059: the control lines ended on an ERR
self._yielded = None # (slot, tokens read): the last request on them gave way
self.wlock = threading.Lock() # stdin writes from several request threads
self.pump = threading.Thread(target=self._pump, daemon=True)
@@ -947,6 +948,7 @@ class StrataEngine:
if len(f) >= 3 and f[1].lstrip("-").isdigit() and f[2].isdigit():
self._yielded = (int(f[1]), int(f[2]))
elif line.startswith("ERR"):
+ self._ctl_erred = True # #1059: the engine refused it and is idle: no DONE follows
raise ValueError(line[4:].strip())
if line.startswith("DONE") and self._ctl_mode == "solo":
self._ctl_result = ("done", None)
@@ -1110,6 +1112,7 @@ class StrataEngine:
self._send(f"{head} {','.join(str(int(t)) for t in prompt)}")
phase = "solo"
self._ctl_mode, self._ctl_result, self._yielded = "solo", None, None
+ self._ctl_erred = False
def others():
with self.slot_cv:
return self.waiting > 0
@@ -1181,6 +1184,7 @@ class StrataEngine:
self.slot_held[slot] = [] # the admission overwrites what the slot held
phase = "admit"
self._ctl_mode, self._ctl_result, self._yielded = "batch", None, None
+ self._ctl_erred = False
asked = False
for x in self._control(cancel, pending.append):
while pending:
@@ -1264,6 +1268,8 @@ class StrataEngine:
try:
if phase in ("solo", "admit") and (self.gen != born or not self.alive()):
phase = "none" # #1012: its engine is gone: nothing to stop or drain
+ if phase in ("solo", "admit") and self._ctl_erred:
+ phase = "none" # #1059: it ended on the engine's ERR: no DONE to wait 300 s for
if phase == "solo":
self._send("STOP")
self._drain_control("DONE", born=born)
diff --git a/serve/test_parallel.py b/serve/test_parallel.py
index ed935ba6f..52b0909b7 100644
--- a/serve/test_parallel.py
+++ b/serve/test_parallel.py
@@ -87,6 +87,9 @@ while True:
slot = int(f[1]) if f[0] == "BGEN" else None
max_new = int(f[2] if f[0] == "BGEN" else f[1])
ids = f[-1].split(",")
+ if bytes(int(x) & 255 for x in ids).find(b"REFUSEME") >= 0: # #1059: refused up front, then idle (no DONE)
+ print("ERR refused: images are not enabled", flush=True)
+ continue
if log:
log.write(f"{f[0]} {slot} {len(ids)} {max(len(active), 0)}\n"); log.flush()
toks = reply(ids)
diff --git a/serve/test_restart_waiters.py b/serve/test_restart_waiters.py
index 9d20e28da..99c28d006 100644
--- a/serve/test_restart_waiters.py
+++ b/serve/test_restart_waiters.py
@@ -184,6 +184,25 @@ class RestartWaiters(unittest.TestCase):
with self.assertRaises(EngineDied):
self.engine._send("STOP")
+ def refused(self, slots):
+ """#1059: the engine refuses a request up front (ERR, then idle). The server answered after a 300 s drain of
+ a DONE that never comes, and held the control lines meanwhile."""
+ self.start(slots)
+ out = {}
+ t0 = time.time()
+ self.post("REFUSEME please", out, 0)
+ self.assertLess(time.time() - t0, 20)
+ self.assertEqual(out[0][0], "http", out)
+ self.assertIn("refused", out[0][2])
+ self.clean()
+ self.assertEqual(self.chat("after")["choices"][0]["message"]["content"], "ok, done.")
+
+ def test_an_engine_err_answers_at_once_solo_loop(self):
+ self.refused(2)
+
+ def test_an_engine_err_answers_at_once_not_batched(self):
+ self.refused(0)
+
def test_solo_engine_is_unchanged(self):
self.start(4, fit=0) # the engine turns batching off
self.kill()