'Call ismaster once or twice. Reset server\'s pool on error.
Returns a ServerDescription.'

def _check_with_retry(self):

    address = self._server_description.address
    retry = True
    metadata = None
    if (self._server_description.server_type == SERVER_TYPE.Unknown):
        retry = False
        metadata = self._pool.opts.metadata
    start = _time()
    try:
        return self._check_once(metadata=metadata)
    except ReferenceError:
        raise
    except Exception as error:
        error_time = (_time() - start)
        if self._publish:
            self._listeners.publish_server_heartbeat_failed(address, error_time, error)
        self._topology.reset_pool(address)
        default = ServerDescription(address, error=error)
        if (not retry):
            self._avg_round_trip_time.reset()
            return default
        start = _time()
        try:
            return self._check_once(metadata=self._pool.opts.metadata)
        except ReferenceError:
            raise
        except Exception as error:
            error_time = (_time() - start)
            if self._publish:
                self._listeners.publish_server_heartbeat_failed(address, error_time, error)
            self._avg_round_trip_time.reset()
            return default
