#NEWLINE# def __call__( self , func , * args , **kwargs ) : #NEWLINE# #INDENT# "Call a function with arguments until it completes without\n        throwing a Kazoo exception\n\n        :param func: Function to call\n        :param args: Positional arguments to call the function with\n        :params kwargs: Keyword arguments to call the function with\n\n        The function will be called until it doesn't throw one of the\n        retryable exceptions (ConnectionLoss, OperationTimeout, or\n        ForceRetryError), and optionally retrying on session\n        expiration.\n\n        " #NEWLINE# self . reset ( ) #NEWLINE# while True : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# if ( ( self . deadline is not None ) and ( self . _cur_stoptime is None ) ) : #NEWLINE# #INDENT# self . _cur_stoptime = ( time . time ( ) + self . deadline ) #NEWLINE# #UNINDENT# return func ( * args , ** kwargs ) #NEWLINE# #UNINDENT# except ConnectionClosedError : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# except self . retry_exceptions : #NEWLINE# #INDENT# if ( self . _attempts == self . max_tries ) : #NEWLINE# #INDENT# raise RetryFailedError ( 'Too many retry attempts' ) #NEWLINE# #UNINDENT# self . _attempts += 1 #NEWLINE# sleeptime = ( self . _cur_delay + ( random . randint ( 0 , self . max_jitter ) / 100.0 ) ) #NEWLINE# if ( ( self . _cur_stoptime is not None ) and ( ( time . time ( ) + sleeptime ) >= self . _cur_stoptime ) ) : #NEWLINE# #INDENT# raise RetryFailedError ( 'Exceeded retry deadline' ) #NEWLINE# #UNINDENT# if self . interrupt : #NEWLINE# #INDENT# while ( sleeptime > 0 ) : #NEWLINE# #INDENT# if ( sleeptime < 0.1 ) : #NEWLINE# #INDENT# self . sleep_func ( sleeptime ) #NEWLINE# sleeptime -= sleeptime #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . sleep_func ( 0.1 ) #NEWLINE# sleeptime -= 0.1 #NEWLINE# #UNINDENT# if self . interrupt ( ) : #NEWLINE# #INDENT# raise InterruptedError ( ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . sleep_func ( sleeptime ) #NEWLINE# #UNINDENT# self . _cur_delay = min ( ( self . _cur_delay * self . backoff ) , self . max_delay )