'Creates and returns a new :class:`~.Session` object.  If `keyspace`
is specified, that keyspace will be the default keyspace for
operations on the ``Session``.'

def connect(self, keyspace=None, wait_for_all_pools=False):

    with self._lock:
        if self.is_shutdown:
            raise DriverException('Cluster    is    already    shut    down')
        if (not self._is_setup):
            log.debug('Connecting    to    cluster,    contact    points:    %s;    protocol    version:    %s', self.contact_points, self.protocol_version)
            self.connection_class.initialize_reactor()
            _register_cluster_shutdown(self)
            for address in self.contact_points_resolved:
                (host, new) = self.add_host(address, signal=False)
                if new:
                    host.set_up()
                    for listener in self.listeners:
                        listener.on_add(host)
            self.profile_manager.populate(weakref.proxy(self), self.metadata.all_hosts())
            try:
                self.control_connection.connect()
                for address in self.contact_points_resolved:
                    h = self.metadata.get_host(address)
                    if (h and (self.profile_manager.distance(h) == HostDistance.IGNORED)):
                        h.is_up = None
                log.debug('Control    connection    created')
            except Exception:
                log.exception('Control    connection    failed    to    connect,    shutting    down    Cluster:')
                self.shutdown()
                raise
            self.profile_manager.check_supported()
            if self.idle_heartbeat_interval:
                self._idle_heartbeat = ConnectionHeartbeat(self.idle_heartbeat_interval, self.get_connection_holders, timeout=self.idle_heartbeat_timeout)
            self._is_setup = True
    session = self._new_session(keyspace)
    if wait_for_all_pools:
        wait_futures(session._initial_connect_futures)
    return session
