@@ -405,6 +405,9 @@ def _launch_server(self, escaped=None):
405405 if not os .path .exists (self ._server_options ["log-file" ]):
406406 raise Exception ("Log not found" )
407407
408+ # Give server a little time to have the endpoints up and ready
409+ time .sleep (10 )
410+
408411 def _validate_log_record (self , record , format_regex , escaped ):
409412 match = format_regex .search (record )
410413 assert match , "Invalid log line"
@@ -483,18 +486,29 @@ def test_injection(self, log_format, format_regex, injected_record):
483486 # TODO Refactor server launch, shutdown into reusable class
484487 wait_time = 10
485488
486- while wait_time and not triton_client .is_server_ready ():
489+ while wait_time :
490+ try :
491+ if triton_client .is_server_ready ():
492+ break
493+ # Gracefully handle connection error if server endpoint isn't up yet
494+ except Exception as e :
495+ print (
496+ f"Client failed to connect, retries remaining: { wait_time } . Error: { e } "
497+ )
498+
487499 time .sleep (1 )
488500 wait_time -= 1
501+ print (f"Server not ready yet, retries remaining: { wait_time } " )
489502
490503 while wait_time and not triton_client .is_model_ready ("simple" ):
491504 time .sleep (1 )
492505 wait_time -= 1
493506
494- if not triton_client .is_server_ready () or not triton_client .is_model_ready (
495- "simple"
496- ):
497- raise Exception ("Model or Server not Ready" )
507+ if not triton_client .is_server_ready ():
508+ raise Exception ("Server not Ready" )
509+
510+ if not triton_client .is_model_ready ("simple" ):
511+ raise Exception ("Model not Ready" )
498512
499513 except Exception as e :
500514 self ._shutdown_server ()
0 commit comments