#NEWLINE# def __call__( self , f ) : #NEWLINE# #INDENT# func_name = reflection . get_callable_name ( f ) #NEWLINE# def _func( * args , **kwargs ) : #NEWLINE# #INDENT# result = None #NEWLINE# try : #NEWLINE# #INDENT# if self . _retry_count : #NEWLINE# #INDENT# LOG . debug ( 'Invoking %(func_name)s; retry count is %(retry_count)d.' , { #NEWLINE# #INDENT# 'func_name' : func_name , #NEWLINE# 'retry_count' : self . _retry_count , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# result = f ( * args , ** kwargs ) #NEWLINE# #UNINDENT# except self . _exceptions : #NEWLINE# #INDENT# with excutils . save_and_reraise_exception ( ) as ctxt : #NEWLINE# #INDENT# LOG . warning ( _LW ( 'Exception which is in the suggested list of exceptions occurred while invoking function: %s.' ) , func_name , exc_info = True ) #NEWLINE# if ( ( self . _max_retry_count != ( - 1 ) ) and ( self . _retry_count >= self . _max_retry_count ) ) : #NEWLINE# #INDENT# LOG . error ( _LE ( 'Cannot retry upon suggested exception since retry count (%(retry_count)d) reached max retry count (%(max_retry_count)d).' ) , { #NEWLINE# #INDENT# 'retry_count' : self . _retry_count , #NEWLINE# 'max_retry_count' : self . _max_retry_count , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ctxt . reraise = False #NEWLINE# self . _retry_count += 1 #NEWLINE# self . _sleep_time += self . _inc_sleep_time #NEWLINE# return self . _sleep_time #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# raise loopingcall . LoopingCallDone ( result ) #NEWLINE# #UNINDENT# def func( * args , **kwargs ) : #NEWLINE# #INDENT# loop = loopingcall . DynamicLoopingCall ( _func , * args , ** kwargs ) #NEWLINE# evt = loop . start ( periodic_interval_max = self . _max_sleep_time ) #NEWLINE# LOG . debug ( 'Waiting for function %s to return.' , func_name ) #NEWLINE# return evt . wait ( ) #NEWLINE# #UNINDENT# return func