def _HostDownPrepareConnect(self):
    now = time.time()
    time_left = self._dampen_end_time - now
    logging.debug('BaseDevice.Connect is waiting because of previous '
                  'connection errors, host is %s, time_left is %s',
                  self.host, time_left)
    if time_left > 0:
      # pylint: disable=g-doc-exception
      raise self.__exc.__class__(
          'Connection to %s(%s) failed. Will not retry for %.1fs.'
          % (self.host, self.loopback_ipv4, time_left),
          dampen_connect=True)
      # pylint: enable=g-doc-exception
    else:
      # Next time, we'll try to connect.
      self._host_status = True
      self.connected = False
Works out if it's safe to retry a connection attempt.
dataset/ETHPy150Open google/capirca/tools/ldpush/base_device.py/BaseDevice._HostDownPrepareConnect