server bench: fix bench not waiting for model load (#7284)

This commit is contained in:
Johannes Gäßler 2024-05-15 08:44:16 +02:00 committed by GitHub
parent 9f773486ab
commit 583fd6b000
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -293,13 +293,14 @@ def start_server_background(args):
def is_server_listening(server_fqdn, server_port): def is_server_listening(server_fqdn, server_port):
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock: try:
result = sock.connect_ex((server_fqdn, server_port)) url = f"{server_fqdn}:{server_port}/health"
_is_server_listening = result == 0 if not url.startswith("http://"):
if _is_server_listening: url = f"http://{url}"
print(f"server is listening on {server_fqdn}:{server_port}...") result = requests.get(url)
return _is_server_listening return result.status_code == 200
except Exception:
return False
def escape_metric_name(metric_name): def escape_metric_name(metric_name):
return re.sub('[^A-Z0-9]', '_', metric_name.upper()) return re.sub('[^A-Z0-9]', '_', metric_name.upper())