def retry_on_failure(f, *args, **kwargs):
 def t(*args, **kwargs):
  for i in xrange(MAX_FAILURE_RETRY):
   try:
    ret_val = f(*args, **kwargs)
    return ret_val
   except Exception as e:
    print ("retry_on_failure(%s): failed on attempt '%d':" % (f.__name__, (i + 1)))
    print e
    excp_info = sys.exc_info()
    continue
  raise excp_info[0], excp_info[1], excp_info[2]
 return t

def retry_on_failure ( f , * args , ** kwargs ) : def t ( * args , ** kwargs ) : for i in xrange ( MAX_FAILURE_RETRY ) : try : ret_val = f ( * args , ** kwargs ) return ret_val except Exception as e : print ( "retry_on_failure(%s): failed on attempt '%d':" % ( f . __name__ , ( i + 1 ) ) ) print e excp_info = sys . exc_info ( ) continue raise excp_info [ 0 ] , excp_info [ 1 ] , excp_info [ 2 ] return t
utility function which: 1 .