From 893908604118d51cb6ab18fc667965d26f6bfd5e Mon Sep 17 00:00:00 2001 From: Jonathon Belotti Date: Thu, 28 Sep 2023 10:18:54 -0400 Subject: [PATCH] fix: don't loop forever if TGI server fails (#456) --- 06_gpu_and_ml/text_generation_inference.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/06_gpu_and_ml/text_generation_inference.py b/06_gpu_and_ml/text_generation_inference.py index e3389ae70..0fbdbcbf0 100644 --- a/06_gpu_and_ml/text_generation_inference.py +++ b/06_gpu_and_ml/text_generation_inference.py @@ -122,6 +122,13 @@ def webserver_ready(): socket.create_connection(("127.0.0.1", 8000), timeout=1).close() return True except (socket.timeout, ConnectionRefusedError): + # Check if launcher webserving process has exited. + # If so, a connection can never be made. + retcode = self.launcher.poll() + if retcode is not None: + raise RuntimeError( + f"launcher exited unexpectedly with code {retcode}" + ) return False while not webserver_ready():