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 that meets a restart in progress gets an EngineDied, not an AttributeError (#1012)
Niko1221b6c2e01589c0
diff --git a/serve/server.py b/serve/server.pyindex e521432de..d6b1fc37e 100644--- a/serve/server.py+++ b/serve/server.py@@ -721,7 +721,8 @@ class StrataEngine:if "issue #29" in line:return ("The engine stopped itself because it had stopped making progress - a hang it caught. Its log ""line: " + line.strip() + " - please report it at github.com/Niko1221/Strata/issues.")- rc = self.proc.poll()+ proc = self.proc # None while a restart has not started the next one yet+ rc = proc.poll() if proc is not None else Noneif rc is not None and rc >= 0 and self.last_err: # its own last words on stdout: they say whyreturn (f"The engine exited (code {rc}) after it reported: {self.last_err} - please report it at ""github.com/Niko1221/Strata/issues with the log.")@@ -734,7 +735,8 @@ class StrataEngine:"smaller model (Q2_0 / IQ2_XS).")def alive(self) -> bool:- return self.proc is not None and not getattr(self, "ended", False) and self.proc.poll() is None+ proc = self.proc # read once: restart() / close() may set it to None meanwhile+ return proc is not None and not getattr(self, "ended", False) and proc.poll() is Nonedef exit_code(self):if self.proc is None:@@ -894,7 +896,7 @@ class StrataEngine:with self.wlock:self.proc.stdin.write(text + "\n")self.proc.stdin.flush()- except OSError: # the pipe is gone: the engine died (not the client)+ except (OSError, AttributeError): # the pipe is gone (or a restart's close() took the process):raise EngineDied(f"the engine stopped unexpectedly (exit code {self.exit_code()})") from Nonedef _control(self, cancel, on_token, stop_when=None):diff --git a/serve/test_restart_waiters.py b/serve/test_restart_waiters.pyindex 22360d23d..9d20e28da 100644--- a/serve/test_restart_waiters.py+++ b/serve/test_restart_waiters.py@@ -171,6 +171,19 @@ class RestartWaiters(unittest.TestCase):def test_killed_while_reading_with_others_arriving(self):self.killed_mid_read(2, 2)+ def test_an_old_request_meets_a_restart_in_progress(self):+ """A request that learns its engine died while restart() has already taken the process (self.proc is None):+ its death note and its sends answer with EngineDied, not AttributeError (the client got no reply at all)."""+ from serve.server import EngineDied+ self.start(2)+ self.kill()+ self.engine.close() # what restart() does first+ self.assertIsNone(self.engine.proc)+ self.assertTrue(self.engine.death_note()) # a sentence, no AttributeError+ self.assertFalse(self.engine.alive())+ with self.assertRaises(EngineDied):+ self.engine._send("STOP")+def test_solo_engine_is_unchanged(self):self.start(4, fit=0) # the engine turns batching offself.kill()