Returns the next connection in this pool that is ready to be
        reused.  Returns None of there aren't any.
333647
def get(self):
        
        # Discard ready connections that are too old.
        self.clean()

        # Return the first connection that is ready, and remove it
        # from the queue.  Connections that aren't ready are returned
        # to the end of the queue with an updated time, on the
        # assumption that somebody is actively reading the response.
        for _ in range(len(self.queue)):
            (conn, _) = self.queue.pop(0)
            if self._conn_ready(conn):
                return conn
            else:
                self.put(conn)
        return None
942690
def _threadsafe_get_connection(self):
        """"""
        self._lock.acquire()
        try:
            next = self._nextConnection
            con = PooledDBConnection(self, self._connections[next])
            next += 1
            if next >= len(self._connections):
                next = 0
            self._nextConnection = next
            return con
        finally:
            self._lock.release()
308634
final ConnectionPoolConnection open() {
      ConnectionPoolConnection conn = availableQueue.poll();
      if(conn != null) {
         if(!testOnLogicalOpen) {
            conn.logicalOpen();
            conn.state.set(ConnectionPoolConnection.STATE_OPEN);
         } else {
            try {
               conn.logicalOpenWithTest();
               conn.state.set(ConnectionPoolConnection.STATE_OPEN);
            } catch(SQLException se) {
               conn.state.set(ConnectionPoolConnection.STATE_REOPENING);
               stats.connectionErrors.mark();
               reopen(conn);
               return open(); //Attempt to open another connection
            }
         }
      }
      return conn;
   }
1130221
def get_connection_by_dest(self, dest):
        ''''''
        with self._mutex:
            for conn in self.connections:
                if conn.has_port(self) and conn.has_port(dest):
                    return conn
            return None
1134948
def connection(self, shareable=True):
        
        if shareable and self._maxshared:
            self._lock.acquire()
            try:
                while (not self._shared_cache and self._maxconnections
                        and self._connections >= self._maxconnections):
                    self._wait_lock()
                if len(self._shared_cache) < self._maxshared:
                    # shared cache is not full, get a dedicated connection
                    try:  # first try to get it from the idle cache
                        con = self._idle_cache.pop(0)
                    except IndexError:  # else get a fresh connection
                        con = self.steady_connection()
                    else:
                        con._ping_check()  # check this connection
                    con = SharedDBConnection(con)
                    self._connections += 1
                else:  # shared cache full or no more connections allowed
                    self._shared_cache.sort()  # least shared connection first
                    con = self._shared_cache.pop(0)  # get it
                    while con.con._transaction:
                        # do not share connections which are in a transaction
                        self._shared_cache.insert(0, con)
                        self._wait_lock()
                        self._shared_cache.sort()
                        con = self._shared_cache.pop(0)
                    con.con._ping_check()  # check the underlying connection
                    con.share()  # increase share of this connection
                # put the connection (back) into the shared cache
                self._shared_cache.append(con)
                self._lock.notify()
            finally:
                self._lock.release()
            con = PooledSharedDBConnection(self, con)
        else:  # try to get a dedicated connection
            self._lock.acquire()
            try:
                while (self._maxconnections
                        and self._connections >= self._maxconnections):
                    self._wait_lock()
                # connection limit not reached, get a dedicated connection
                try:  # first try to get it from the idle cache
                    con = self._idle_cache.pop(0)
                except IndexError:  # else get a fresh connection
                    con = self.steady_connection()
                else:
                    con._ping_check()  # check connection
                con = PooledDedicatedDBConnection(self, con)
                self._connections += 1
            finally:
                self._lock.release()
        return con
361978
def next(self):
        
        step = self.raw.get('max_results', 1000)
        start = self.raw.get('start_index', 1) + step
        self.raw['start_index'] = start
        return self
690462
def next(self):
        
        if self._order_by == 'oldest':
            return self.newer
        if self._order_by == 'newest':
            return self.older
        return None
748610
public final int getActiveConnectionCount() {

      if(!isActive) {
         return 0;
      }

      int count = 0;
      for(ConnectionPoolConnection conn : connections) {
         if(conn.state.get() != ConnectionPoolConnection.STATE_AVAILABLE) {
            count++;
         }
      }

      return count;
   }
1266988
def get_random_connection(self):
        
        if self._available_connections:
            node_name = random.choice(list(self._available_connections.keys()))
            conn_list = self._available_connections[node_name]
            # check it in case of empty connection list
            if conn_list:
                return conn_list.pop()
        for node in self.nodes.random_startup_node_iter():
            connection = self.get_connection_by_node(node)

            if connection:
                return connection

        raise Exception("Cant reach a single startup node.")
112209
def connections(self):
        
        if not self.__connections:
            self.__connections = Connections(
                self.__connection)
        return self.__connections
273316
def next(self):
        
        if not self._cache:
            self._cache = self._get_results()
            self._retrieved += len(self._cache)

        # If we don't have any other data to return, we just
        # stop the iteration.
        if not self._cache:
            raise StopIteration()

        # Consuming the cache and updating the "cursor"
        return self._cache.pop(0)
703304
def try_next(self):
        
        with self.condition:
            try:
                return self.force[0]
            except IndexError:
                pass

            return self._get_next(False)
1295769
private PooledConnection getConnectionDirect() throws SQLException {
		if (null == freePool) {
			throw new SQLException("PooledDataSource is closed!");
		}

		final int maxActive = config.getMaxActive();
		if (maxActive <= 0 || maxActive < this.activeCount) {
			// 超过最大使用限制
			throw new SQLException("In used Connection is more than Max Active.");
		}

		PooledConnection conn = freePool.poll();
		if (null == conn || conn.open().isClosed()) {
			conn = this.newConnection();
		}
		activeCount++;
		return conn;
	}
1360485
def next(self) -> Future:
        
        self._running_future = Future()

        if self._finished:
            self._return_result(self._finished.popleft())

        return self._running_future
1255879
private ConnectionData findConnectionDataToUse()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "findConnectionDataToUse");

        // Look through the the connection data in this group to try and find
        // a connection with the lowest use count.
        ConnectionData connectionDataToUse = null;

        synchronized (connectionData)
        {
            int lowestUseCount = conversationsPerConnection;
            for (int i = 0; i < connectionData.size(); ++i)
            {
                final ConnectionData cd = connectionData.get(i);

                if (cd.getUseCount() < lowestUseCount)
                {
                    lowestUseCount = cd.getUseCount();
                    connectionDataToUse = cd;
                }
            }

            // If we cannot find a suitable connection data object, see if the
            // idle connections pool has a connection we could use to create one.
            if (connectionDataToUse == null)
            {
                final IdleConnectionPool p = IdleConnectionPool.getInstance();
                final OutboundConnection oc = p.remove(groupEndpointDescriptor);
                if (oc != null)
                {
                    connectionDataToUse = new ConnectionData(this, groupEndpointDescriptor);
                    oc.setConnectionData(connectionDataToUse);
                    connectionDataToUse.setConnection(oc);
                    connectionData.add(connectionDataToUse);

                }
            }

            // If we now have a connectionDataToUse, increment its use count NOW
            // so that it won't get accidentally added to the idle pool
            if (connectionDataToUse != null)
            {
                connectionDataToUse.incrementUseCount();
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "findConnectionDataToUse", connectionDataToUse);
        return connectionDataToUse;
    }
869744
def next(self):
        """"""
        # pylint: disable=protected-access
        while True:
            if self._pcontext.thread_num == 0 and self._pcontext.num_threads > 1:
                # Producer.
                for iter_elem in self._iterable:
                    self._queue.put(iter_elem, timeout=self._element_timeout)
                for _ in range(self._pcontext.num_threads - 1):
                    self._queue.put(
                        "__queueend__:%d" % (self._pcontext._thread_loop_ids[0])
                    )
                raise StopIteration()
            elif self._pcontext.num_threads > 1:
                # Consumer.
                # Check that the pool still deals with this loop.
                # pylint: disable=protected-access
                with self._pcontext._queuelock:
                    pool_loop_reached = max(self._pcontext._thread_loop_ids)
                    master_reached = self._pcontext._thread_loop_ids[0]
                if pool_loop_reached > self._loop_id:
                    raise StopIteration()
                elif master_reached < self._loop_id:
                    # The producer did not reach this loop yet.
                    _time.sleep(.1)
                    continue
                else:
                    try:
                        queue_elem = self._queue.get(timeout=0.1)
                    except _Queue.Empty:
                        continue
                    if queue_elem == "__queueend__:%d" % self._loop_id:
                        raise StopIteration()
                    else:
                        return queue_elem
            else:
                # Single thread execution.
                # Should have never reached here, since this case is dealt with
                # in the __iter__ method!
                raise Exception("Internal error!")
1106400
def next(self):
        
        self.open_read()
        data = self.resp.read(self.BufferSize)
        if not data:
            self.close()
            raise StopIteration
        return data