Let the test server open its port without asking who 127.0.0.1 is

The stand-in whisper server in the ggml tests is an http.server, and
http.server looks up the reverse name of the address it bound in between
the bind and the listen. On Linux that answers at once. On a Mac nothing
answers and the lookup sits in a resolver timeout for thirty-five
seconds, with the port closed the whole time and _wait_ready watching it.

Seven tests start a server and one of them starts two, so the macOS job
spent 330 of its 334 seconds inside that lookup while the same suite took
fifteen seconds on Linux. Binding through socketserver and naming the
server after the address it already has skips the question.
This commit is contained in:
2026-08-16 11:57:55 +03:00
parent 2b9f91687c
commit 1135362afa
+12 -2
View File
@@ -439,7 +439,7 @@ class Catalogue(Local):
STAND_IN = textwrap.dedent("""
import http.server, sys, threading, time
import http.server, socketserver, sys, threading, time
args = sys.argv[1:]
@@ -465,7 +465,17 @@ STAND_IN = textwrap.dedent("""
def log_message(self, *a):
pass
server = http.server.HTTPServer((opt("--host"), int(opt("--port"))), Handler)
# The same server, without the reverse lookup of the address it bound.
# http.server asks the resolver for the name behind 127.0.0.1 in between
# binding and listening; on a Mac nothing answers and the call sits in a
# timeout for half a minute, all of it with the port still closed and a
# start waiting on it.
class Bound(http.server.HTTPServer):
def server_bind(self):
socketserver.TCPServer.server_bind(self)
self.server_name, self.server_port = self.server_address[:2]
server = Bound((opt("--host"), int(opt("--port"))), Handler)
print("listening on " + opt("--port"), flush=True)
server.serve_forever()
""")