@@ -766,7 +766,6 @@ def __init__(
766766 launch_server : bool = True ,
767767 docker_config : DockerConfig = RUNNING_DOCKER ,
768768 use_pypim : bool = True ,
769- num_connection_tryouts : int = 3 ,
770769 context : server_context .AvailableServerContexts = server_context .SERVER_CONTEXT ,
771770 ):
772771 # Load DPFClientAPI
@@ -786,6 +785,7 @@ def __init__(
786785 address = f"{ ip } :{ port } "
787786
788787 self ._remote_instance = None
788+ start_time = time .time ()
789789 if launch_server :
790790 if (
791791 is_pypim_configured ()
@@ -818,7 +818,7 @@ def __init__(
818818 self ._input_port = port
819819 self .live = True
820820 self ._create_shutdown_funcs ()
821- self ._check_first_call (num_connection_tryouts )
821+ self ._check_first_call (timeout = timeout - ( time . time () - start_time )) # Pass remaining time
822822 if context :
823823 if context == core .AvailableServerContexts .no_context :
824824 self ._base_service .initialize ()
@@ -831,15 +831,16 @@ def __init__(
831831 pass
832832 self .set_as_global (as_global = as_global )
833833
834- def _check_first_call (self , num_connection_tryouts ):
835- for i in range (num_connection_tryouts ):
834+ def _check_first_call (self , timeout : float ):
835+ start_time = time .time ()
836+ while time .time () - start_time < timeout :
836837 try :
837- self .version
838+ _ = self .version
838839 break
839840 except errors .DPFServerException as e :
840- if ( "GOAWAY" not in str (e .args ) and "unavailable" not in str (e .args )) or i == (
841- num_connection_tryouts - 1
842- ) :
841+ if "GOAWAY" in str (e .args ) or "unavailable" in str (e .args ):
842+ time . sleep ( 0.5 )
843+ else :
843844 raise e
844845
845846 @property
0 commit comments