@@ -445,7 +445,7 @@ def seek_once(self, msg):
445
445
if pos != - 1 :
446
446
return pos
447
447
448
- def seek_wait (self , msg , proc = None , name = None ):
448
+ def seek_wait (self , msg , proc = None , name = None , timeout = 90 ):
449
449
while True :
450
450
if os .path .exists (self .path ):
451
451
break
@@ -454,7 +454,8 @@ def seek_wait(self, msg, proc=None, name=None):
454
454
with open (self .path , 'r' ) as f :
455
455
f .seek (self .log_begin , os .SEEK_SET )
456
456
cur_pos = self .log_begin
457
- while True :
457
+ current_time = time .time ()
458
+ while current_time + timeout > time .time ():
458
459
if not (proc is None ):
459
460
if not (proc .poll () is None ):
460
461
raise TarantoolStartError (name )
@@ -464,8 +465,9 @@ def seek_wait(self, msg, proc=None, name=None):
464
465
f .seek (cur_pos , os .SEEK_SET )
465
466
continue
466
467
if re .findall (msg , log_str ):
467
- return
468
+ return True
468
469
cur_pos = f .tell ()
470
+ return False
469
471
470
472
471
473
class TarantoolServer (Server ):
@@ -756,7 +758,8 @@ def install(self, silent=True):
756
758
757
759
def deploy (self , silent = True , ** kwargs ):
758
760
self .install (silent )
759
- self .start (silent = silent , ** kwargs )
761
+ if not self .start (silent = silent , ** kwargs ):
762
+ return False
760
763
761
764
def copy_files (self ):
762
765
if self .script :
@@ -829,7 +832,7 @@ def cleanup(self, *args, **kwargs):
829
832
* args , ** kwargs )
830
833
831
834
def start (self , silent = True , wait = True , wait_load = True , rais = True , args = [],
832
- ** kwargs ):
835
+ server_start_timeout = 90 , ** kwargs ):
833
836
if self ._start_against_running :
834
837
return
835
838
if self .status == 'started' :
@@ -880,7 +883,9 @@ def start(self, silent=True, wait=True, wait_load=True, rais=True, args=[],
880
883
881
884
if wait :
882
885
try :
883
- self .wait_until_started (wait_load )
886
+ if not self .wait_until_started (
887
+ wait_load , server_start_timeout = server_start_timeout ):
888
+ return False
884
889
except TarantoolStartError :
885
890
# Python tests expect we raise an exception when non-default
886
891
# server fails
@@ -1090,22 +1095,26 @@ def kill_old_server(self, silent=True):
1090
1095
self .wait_until_stopped (pid )
1091
1096
return True
1092
1097
1093
- def wait_until_started (self , wait_load = True ):
1098
+ def wait_until_started (self , wait_load = True , server_start_timeout = 90 ):
1094
1099
""" Wait until server is started.
1095
1100
1096
1101
Server consists of two parts:
1097
1102
1) wait until server is listening on sockets
1098
1103
2) wait until server tells us his status
1099
1104
1100
1105
"""
1101
- color_log ('DEBUG: [Instance {}] Waiting until started '
1102
- '(wait_load={})\n ' .format (self .name , str (wait_load )),
1103
- schema = 'info' )
1106
+ color_log (
1107
+ 'DEBUG: [Instance {}] Waiting until started '
1108
+ '(wait_load={}, start_timeout={})\n ' .format (
1109
+ self .name , str (wait_load ), str (server_start_timeout )),
1110
+ schema = 'info' )
1104
1111
1105
1112
if wait_load :
1106
1113
msg = 'entering the event loop|will retry binding|hot standby mode'
1107
1114
p = self .process if not self .gdb and not self .lldb else None
1108
- self .logfile_pos .seek_wait (msg , p , self .name )
1115
+ if not self .logfile_pos .seek_wait (
1116
+ msg , p , self .name , server_start_timeout ):
1117
+ return False
1109
1118
while True :
1110
1119
try :
1111
1120
temp = AdminConnection ('localhost' , self .admin .port )
0 commit comments