#NEWLINE# def __wrap_methods_with_call_and_maybe_retry( self , name ) : #NEWLINE# #INDENT# 'Wrap calls to name().' #NEWLINE# def call_and_maybe_retry( * args , **kwargs ) : #NEWLINE# #INDENT# n = len ( self . __alternatives ) #NEWLINE# for i in range ( n ) : #NEWLINE# #INDENT# index = ( ( self . __start_index + i ) % n ) #NEWLINE# alternative = self . __alternatives [ index ] #NEWLINE# try : #NEWLINE# #INDENT# result = getattr ( alternative , name ) ( * args , ** kwargs ) #NEWLINE# self . __start_index = index #NEWLINE# return result #NEWLINE# #UNINDENT# except Exception as ex : #NEWLINE# #INDENT# if ( ( i < ( n - 1 ) ) and self . __retry_if ( ex ) ) : #NEWLINE# #INDENT# log . info ( ( '%r.%s() raised %r, trying next alternative' % ( alternative , name , ex ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# f = getattr ( self . __alternatives [ self . __start_index ] , name ) #NEWLINE# return wraps ( f ) ( f )