#NEWLINE# def _test_connection( engine , max_retries , retry_interval ) : #NEWLINE# #INDENT# if ( max_retries == ( - 1 ) ) : #NEWLINE# #INDENT# attempts = itertools . count ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# attempts = six . moves . range ( max_retries ) #NEWLINE# #UNINDENT# de_ref = None #NEWLINE# for attempt in attempts : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# return engine . connect ( ) #NEWLINE# #UNINDENT# except exception . DBConnectionError as de : #NEWLINE# #INDENT# msg = _LW ( 'SQL connection failed. %s attempts left.' ) #NEWLINE# LOG . warning ( msg , ( max_retries - attempt ) ) #NEWLINE# time . sleep ( retry_interval ) #NEWLINE# de_ref = de #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( de_ref is not None ) : #NEWLINE# #INDENT# six . reraise ( type ( de_ref ) , de_ref )