def _should_retry_response(resp_status, content):
 if (resp_status >= 500):
  return True
 if (resp_status == _TOO_MANY_REQUESTS):
  return True
 if (resp_status == six.moves.http_client.FORBIDDEN):
  if (not content):
   return False
  try:
   data = json.loads(content.decode('utf-8'))
   reason = data['error']['errors'][0]['reason']
  except (UnicodeDecodeError, ValueError, KeyError):
   LOGGER.warning('Invalid JSON content from response: %s', content)
   return False
  LOGGER.warning('Encountered 403 Forbidden with reason "%s"', reason)
  if (reason in ('userRateLimitExceeded', 'rateLimitExceeded')):
   return True
 return False

def _should_retry_response ( resp_status , content ) : if ( resp_status >= 500 ) : return True if ( resp_status == _TOO_MANY_REQUESTS ) : return True if ( resp_status == six . moves . http_client . FORBIDDEN ) : if ( not content ) : return False try : data = json . loads ( content . decode ( 'utf-8' ) ) reason = data [ 'error' ] [ 'errors' ] [ 0 ] [ 'reason' ] except ( UnicodeDecodeError , ValueError , KeyError ) : LOGGER . warning ( 'Invalid JSON content from response: %s' , content ) return False LOGGER . warning ( 'Encountered 403 Forbidden with reason "%s"' , reason ) if ( reason in ( 'userRateLimitExceeded' , 'rateLimitExceeded' ) ) : return True return False
determines whether a response should be retried .