Take the process with a start that goes wrong

_wait_ready can raise rather than return, and the process it was waiting on
is ours with nothing else holding a reference to it. Leaving it running
leaks a loaded model with nobody left to ask it anything, which is the
whole failure this class is careful about everywhere else. Found by two
stand-in servers still running after a test run.
This commit is contained in:
yusufipk
2026-08-01 20:09:00 +03:00
parent 2cfbbb2d99
commit 634b46fcb0
2 changed files with 48 additions and 10 deletions
+16
View File
@@ -509,6 +509,22 @@ class Servers(Local):
def test_no_pid_file_is_nothing_to_sweep(self):
self.assertFalse(self.server().sweep())
def test_a_start_that_goes_wrong_takes_its_process_with_it(self):
started = []
def explode(inner, proc, port):
started.append(proc)
raise RuntimeError("something in the wait went wrong")
self.patch_attr(ggml.Server, "_wait_ready", explode)
server = self.server()
with self.assertRaises(RuntimeError):
server.serve()
# Nothing else holds a reference to it, so leaving it running would leak
# a loaded model with nobody left to ask it anything.
self.assertIsNotNone(started[0].poll())
self.assertFalse(server.sweep()) # and the pid file went with it
class Arguments(Local):
"""What the two command lines say, since neither program is here to say it."""