For an already established connection return its state.
5226
def get_connection_state(self, connection: str) -> Dict[str, Any]:
        
        if connection not in self.connections:
            raise ConnectionNotOpen(connection)

        return self.connections[connection].state
1235845
def new_conn(self):
        
        """
        :return:
        """
        logger.debug("Opening new connection to rethinkdb with args=%s" % self._conn_args)
        return ConnectionWrapper(self._pool, **self._conn_args)
71965
def get_connection_cls(cls):
        
        if cls.__connection_cls is None:
            cls.__connection_cls, _ = cls.from_settings()
        return cls.__connection_cls
1090396
def make_connection(self):
        ""
        if self._created_connections >= self.max_connections:
            raise ConnectionError("Too many connections")
        self._created_connections += 1
        return self.connection_class(**self.connection_kwargs)
375232
def connection(self):
        
        connection = getattr(self.state, "connection", None)
        if connection is None:
            connection = self.state.connection = pika.BlockingConnection(
                parameters=self.parameters)
            self.connections.add(connection)
        return connection
205695
def _GetConnection(self):
		
		#Attempt to get a connection. If all connections are in use and we have reached the max number of connections,
		#we wait 1 second and try again.
		#The Connection is returned locked to be thread safe
		while self.conn is None:
			self.conn = Pool().GetConnection(self.connInfo)
			if self.conn is not None:
				break
			else:
				time.sleep(1)
476088
private Object reInitialize(Object connection, Set<String> rowKeys)
    {
        /*
         * if(!rowKeys.isEmpty()) {
         */
        connection = getConnection();
        // }
        return connection;
    }
367522
def release(self, connection):
        ""
        self._checkpid()
        if connection.pid != self.pid:
            return
        self._in_use_connections.remove(connection)
        # discard connection with unread response
        if connection.awaiting_response:
            connection.disconnect()
            self._created_connections -= 1
        else:
            self._available_connections.append(connection)
333467
def connected(self, node_id):
        """"""
        conn = self._conns.get(node_id)
        if conn is None:
            return False
        return conn.connected()
5869
def _maybe_reconnect(self):
    """"""
    with self._lock:
      if not self._connected: 
        _LOGGER.info("Connecting")
        self._do_login_locked()
        self._connected = True
        self._connect_cond.notify_all()
        _LOGGER.info("Connected")
127730
private Object getConnection()
    {
        /*
         * Jedis connection = factory.getConnection();
         * 
         * // If resource is not null means a transaction in progress.
         * 
         * if (settings != null) { for (String key : settings.keySet()) {
         * connection.configSet(key, settings.get(key).toString()); } }
         * 
         * if (resource != null && resource.isActive()) { return
         * ((RedisTransaction) resource).bindResource(connection); } else {
         * return connection; } if (resource == null || (resource != null &&
         * !resource.isActive()))
         */
        // means either transaction resource is not bound or it is not active,
        // but connection has already by initialized
        if (isBoundTransaction() && this.connection != null)
        {
            return this.connection;
        }

        // if running within transaction boundary.
        if (resource != null && resource.isActive())
        {
            // no need to get a connection from pool, as nested MULTI is not yet
            // supported.
            if (((RedisTransaction) resource).isResourceBound())
            {
                return ((RedisTransaction) resource).getResource();
            }
            else
            {
                Jedis conn = getAndSetConnection();
                return ((RedisTransaction) resource).bindResource(conn);
            }

        }
        else
        {
            Jedis conn = getAndSetConnection();
            return conn;
        }
    }
689014
def _ensure_connection(self):
        """"""
        conn = self.connect()
        if conn.recycle and conn.recycle < time.time():
            logger.debug('Client session expired after %is. Recycling.', self._recycle)
            self.close()
            conn = self.connect()
        return conn
649842
def connection(self, name=None):
        
        name, type = self._parse_connection_name(name)

        if name not in self._connections:
            logger.debug("Initiating connection %s" % name)
            connection = self._make_connection(name)

            self._set_connection_for_type(connection, type)

            self._connections[name] = self._prepare(connection)

        return self._connections[name]
133679
def _get_state():
    '''
    
    '''
    try:
        return pyconnman.ConnManager().get_property('State')
    except KeyError:
        return 'offline'
    except dbus.DBusException as exc:
        raise salt.exceptions.CommandExecutionError('Connman daemon error: {0}'.format(exc))
871134
async def connect(self):
        '''
        '''
        assert not self.closed
        connection = await self._get()
        return PoolConnection(self, connection)
1185686
def verify_state(self):
        """"""
        if self.state == CONNECTING:
            self.state = OPEN

            self.conn.on_open(self.conn_info)
356668
def new_connection_status(self, conn_status):
        """"""
        if conn_status.status == CONNECTION_STATUS_CONNECTED:
            self._mz.update_members()
        if (conn_status.status == CONNECTION_STATUS_DISCONNECTED or
                conn_status.status == CONNECTION_STATUS_LOST):
            self._mz.reset_members()