@@ -307,21 +307,30 @@ def wait_until_stopped(self, timeout=BITCOIND_PROC_WAIT_TIMEOUT):
307
307
wait_until (self .is_node_stopped , timeout = timeout )
308
308
309
309
@contextlib .contextmanager
310
- def assert_debug_log (self , expected_msgs ):
310
+ def assert_debug_log (self , expected_msgs , timeout = 2 ):
311
+ time_end = time .time () + timeout
311
312
debug_log = os .path .join (self .datadir , self .chain , 'debug.log' )
312
313
with open (debug_log , encoding = 'utf-8' ) as dl :
313
314
dl .seek (0 , 2 )
314
315
prev_size = dl .tell ()
315
316
try :
316
317
yield
317
318
finally :
318
- with open (debug_log , encoding = 'utf-8' ) as dl :
319
- dl .seek (prev_size )
320
- log = dl .read ()
321
- print_log = " - " + "\n - " .join (log .splitlines ())
322
- for expected_msg in expected_msgs :
323
- if re .search (re .escape (expected_msg ), log , flags = re .MULTILINE ) is None :
324
- self ._raise_assertion_error ('Expected message "{}" does not partially match log:\n \n {}\n \n ' .format (expected_msg , print_log ))
319
+ while True :
320
+ found = True
321
+ with open (debug_log , encoding = 'utf-8' ) as dl :
322
+ dl .seek (prev_size )
323
+ log = dl .read ()
324
+ print_log = " - " + "\n - " .join (log .splitlines ())
325
+ for expected_msg in expected_msgs :
326
+ if re .search (re .escape (expected_msg ), log , flags = re .MULTILINE ) is None :
327
+ found = False
328
+ if found :
329
+ return
330
+ if time .time () >= time_end :
331
+ break
332
+ time .sleep (0.05 )
333
+ self ._raise_assertion_error ('Expected messages "{}" does not partially match log:\n \n {}\n \n ' .format (str (expected_msgs ), print_log ))
325
334
326
335
@contextlib .contextmanager
327
336
def assert_memory_usage_stable (self , * , increase_allowed = 0.03 ):
0 commit comments