#NEWLINE# def run( self , **kwargs ) : #NEWLINE# #INDENT# interval = kwargs . get ( 'interval' ) #NEWLINE# while True : #NEWLINE# #INDENT# start = time . time ( ) #NEWLINE# if self . _lock . acquire ( ) : #NEWLINE# #INDENT# self . run_once ( ** kwargs ) #NEWLINE# run_time = ( time . time ( ) - start ) #NEWLINE# logger . info ( 'Scheduler iteration took %d seconds.' , run_time ) #NEWLINE# sleep_time = ( interval - max ( run_time , 0 ) ) #NEWLINE# logger . info ( 'Scheduler sleeping for %d seconds.' , sleep_time ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# sleep_time = 10 #NEWLINE# logger . info ( 'Failed to acquire lock, sleeping for %d seconds.' , sleep_time ) #NEWLINE# #UNINDENT# time . sleep ( sleep_time )