def _execute_with_retries(conn, function, **kwargs):
 r = {}
 max_attempts = 18
 max_retry_delay = 10
 for attempt in range(max_attempts):
  log.info('attempt: {0} function: {1}'.format(attempt, function))
  try:
   fn = getattr(conn, function)
   r['result'] = fn(**kwargs)
   return r
  except botocore.exceptions.ClientError as e:
   error_code = e.response['Error']['Code']
   if (('LimitExceededException' in error_code) or ('ResourceInUseException' in error_code)):
    log.debug('Retrying due to AWS exception {0}'.format(e))
    time.sleep(_jittered_backoff(attempt, max_retry_delay))
   else:
    r['error'] = e.response['Error']
    r['result'] = None
    return r
 r['error'] = 'Tried to execute function {0} {1} times, but was unable'.format(function, max_attempts)
 return r

def _execute_with_retries ( conn , function , ** kwargs ) : r = { } max_attempts = 18 max_retry_delay = 10 for attempt in range ( max_attempts ) : log . info ( 'attempt: {0} function: {1}' . format ( attempt , function ) ) try : fn = getattr ( conn , function ) r [ 'result' ] = fn ( ** kwargs ) return r except botocore . exceptions . ClientError as e : error_code = e . response [ 'Error' ] [ 'Code' ] if ( ( 'LimitExceededException' in error_code ) or ( 'ResourceInUseException' in error_code ) ) : log . debug ( 'Retrying due to AWS exception {0}' . format ( e ) ) time . sleep ( _jittered_backoff ( attempt , max_retry_delay ) ) else : r [ 'error' ] = e . response [ 'Error' ] r [ 'result' ] = None return r r [ 'error' ] = 'Tried to execute function {0} {1} times, but was unable' . format ( function , max_attempts ) return r
retry if were rate limited by aws or blocked by another call .