Prefill the connection pool
351572
@Override
   public void prefill()
   {
      if (isShutdown())
         return;

      if (poolConfiguration.isPrefill())
      {
         ManagedConnectionPool mcp = pools.get(getPrefillCredential());

         if (mcp == null)
         {
            // Trigger the initial-pool-size prefill by creating the ManagedConnectionPool
            getManagedConnectionPool(getPrefillCredential());
         }
         else
         {
            // Standard prefill request
            mcp.prefill();
         }
      }
   }
406072
def _fill_free_pool(self, override_min):
        
        while self.size < self.minsize:
            self._acquiring += 1
            try:
                conn = yield from connect(
                    database=self._database,
                    echo=self._echo,
                    loop=self._loop,
                    **self._conn_kwargs
                )
                self._free.append(conn)
                self._cond.notify()
            finally:
                self._acquiring -= 1
        if self._free:
            return

        if override_min and self.size < self.maxsize:
            self._acquiring += 1
            try:
                conn = yield from connect(
                    database=self._database,
                    echo=self._echo,
                    loop=self._loop,
                    **self._conn_kwargs
                )
                self._free.append(conn)
                self._cond.notify()
            finally:
                self._acquiring -= 1
1367554
def create_pool(module, max_conns, *args, **kwargs):
    
    if not hasattr(module, 'threadsafety'):
        raise NotSupported("Cannot determine driver threadsafety.")
    if max_conns < 1:
        raise ValueError("Minimum number of connections is 1.")
    if module.threadsafety >= 2:
        return Pool(module, max_conns, *args, **kwargs)
    if module.threadsafety >= 1:
        return DummyPool(module, *args, **kwargs)
    raise ValueError("Bad threadsafety level: %d" % module.threadsafety)
678475
function(pool) {
    const conn = new Connection(options.connOptions);
    return conn
      .connect()
      .then(() => {
        if (pool.closed) {
          conn
            .end()
            .then(() => {})
            .catch(() => {});
          return Promise.reject(
            Errors.createError(
              'Cannot create new connection to pool, pool closed',
              true,
              null,
              '08S01',
              Errors.ER_ADD_CONNECTION_CLOSED_POOL,
              null
            )
          );
        }

        conn.releaseWithoutError = () => {
          conn.release().catch(() => {});
        };

        conn.forceEnd = conn.end;

        conn.release = () => {
          if (pool.closed) {
            pool._discardConnection(conn);
            return Promise.resolve();
          }
          if (options.noControlAfterUse) {
            pool._releaseConnection(conn);
            return Promise.resolve();
          }
          //if server permit it, reset the connection, or rollback only if not
          let revertFunction = conn.rollback;
          if (
            options.resetAfterUse &&
            ((conn.info.isMariaDB() && conn.info.hasMinVersion(10, 2, 4)) ||
              (!conn.info.isMariaDB() && conn.info.hasMinVersion(5, 7, 3)))
          ) {
            revertFunction = conn.reset;
          }

          return revertFunction()
            .then(() => {
              pool._releaseConnection(conn);
              return Promise.resolve();
            })
            .catch(err => {
              //uncertain connection state.
              // discard it
              pool._discardConnection(conn);
              return Promise.resolve();
            });
        };
        conn.end = conn.release;
        return Promise.resolve(conn);
      })
      .catch(err => {
        return Promise.reject(err);
      });
  }
335416
public void join()
    {
        while(isStarted()&&_pool!=null)
        {
            synchronized(_join)
            {
                try
                {
                    if(isStarted()&&_pool!=null)
                        _join.wait(30000);
                }
                catch(Exception e)
                {
                    LogSupport.ignore(log,e);
                }
            }
        }
    }
75883
function(callback)
    {
        self.pool = (require('mysql')).createPool({
            user     : self.config.username,
            password : self.config.password,
            database : self.config.db,
            host     : self.config.host,
            port     : self.config.port
        });

        // Initiate a connection - just to proof configuration
        self.pool.getConnection(function(err, connection) {

            if (err || !connection) {
                callback && callback(err);
                return;
            }

            self.prepare(connection);

            // The connection can be closed immediately
            connection.release();
            return callback && callback(null, self.pool);
        });
    }
35600
public function onReady()
    {
        if ($this->pool->config->protologging->value) {
            Daemon::log("New connection\n\n");
        }
        $e = explode('.', $this->protover);
        $packet = pack('nn', $e[0], $e[1]);

        if (strlen($this->user)) {
            $packet .= "user\x00" . $this->user . "\x00";
        }

        if (strlen($this->dbname)) {
            $packet .= "database\x00" . $this->dbname . "\x00";
        }
        elseif (strlen($this->path)) {
            $packet .= "database\x00" . $this->path . "\x00";
        }

        if (strlen($this->options)) {
            $packet .= "options\x00" . $this->options . "\x00";
        }

        $packet .= "\x00";
        $this->sendPacket('', $packet);
    }
203445
private function processConnectionPool(): void
    {
        $readableConnections = $this->connectionPool->getReadableConnections(5);

        foreach ($readableConnections as $id => $connection) {
            if (!isset($this->connectionHandlers[$id])) {
                $this->connectionHandlers[$id] = $this->connectionHandlerFactory->createConnectionHandler($this->kernel, $connection);
            }

            try {
                $statusCodes = $this->connectionHandlers[$id]->ready();
                $this->considerStatusCodes($statusCodes);
            } catch (UserlandDaemonException $exception) {
                $this->daemonOptions->getOption(DaemonOptions::LOGGER)->error($exception->getMessage());
            }

            if ($this->connectionHandlers[$id]->isClosed()) {
                unset($this->connectionHandlers[$id]);
            }
        }
    }
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)
315497
def create_connection():
    """"""

    global _cached_connection
    settings = oz.settings

    if settings["redis_cache_connections"] and _cached_connection != None:
        return _cached_connection
    else:
        conn = redis.StrictRedis(
            host=settings["redis_host"],
            port=settings["redis_port"],
            db=settings["redis_db"],
            password=settings["redis_password"],
            decode_responses=settings["redis_decode_responses"],
            ssl=settings["redis_use_ssl"],
            ssl_keyfile=settings["redis_ssl_keyfile"],
            ssl_certfile=settings["redis_ssl_certfile"],
            ssl_cert_reqs=settings["redis_ssl_cert_reqs"],
            ssl_ca_certs=settings["redis_ssl_ca_certs"]
        )

        if settings["redis_cache_connections"]:
            _cached_connection = conn

        return conn
770704
def connection_from_context(self, request_context):
        
        scheme = request_context['scheme'].lower()
        pool_key_constructor = self.key_fn_by_scheme[scheme]
        pool_key = pool_key_constructor(request_context)

        return self.connection_from_pool_key(pool_key, request_context=request_context)
1232972
private void addToPool(SessionProtocol actualProtocol, PoolKey key, PooledChannel pooledChannel) {
        assert eventLoop.inEventLoop() : Thread.currentThread().getName();
        getOrCreatePool(actualProtocol, key).addLast(pooledChannel);
    }
41586
def init_poolmanager(self, connections, maxsize,
                         block=requests.adapters.DEFAULT_POOLBLOCK,
                         **pool_kwargs):
        """"""
        context = create_urllib3_context(ciphers=self.CIPHERS,
                                         ssl_version=ssl.PROTOCOL_TLSv1)
        pool_kwargs['ssl_context'] = context
        return super(TLSv1Adapter, self).init_poolmanager(connections, maxsize,
                                                          block, **pool_kwargs)
1349823
function initConnectionPool() {

  var setting = {
    hostname: config.oracle.host,
    port    : config.oracle.port,
    database: config.oracle.dbname,
    user    : config.oracle.user,
    password: config.oracle.pass,
    pool    : {
      name: "oracle",
      log : false,
      max : config.oracle.pool
    }
  };

  console.log("Oracle code: " + setting.database);
  console.log("Oracle host: " + setting.hostname);
  console.log("Oracle port: " + setting.port);
  console.log("Oracle pool: " + setting.pool.max);
  console.log("Oracle user: " + setting.user);

  return generic.Pool({
    name   : setting.pool.name,
    log    : setting.pool.log,
    max    : setting.pool.max,
    create : function (callback) {
      oracle().connect(setting, function (err, connection) {
        callback(err, connection);
      });
    },
    destroy: function (connection) {
      connection.close();
    }
  });
}
887412
def _prepare_connection(**kwargs):
    '''
    
    '''
    init_args = {}
    fun_kwargs = {}
    netmiko_kwargs = __salt__['config.get']('netmiko', {})
    netmiko_kwargs.update(kwargs)  # merge the CLI args with the opts/pillar
    netmiko_init_args, _, _, netmiko_defaults = inspect.getargspec(BaseConnection.__init__)
    check_self = netmiko_init_args.pop(0)
    for karg, warg in six.iteritems(netmiko_kwargs):
        if karg not in netmiko_init_args:
            if warg is not None:
                fun_kwargs[karg] = warg
            continue
        if warg is not None:
            init_args[karg] = warg
    conn = ConnectHandler(**init_args)
    return conn, fun_kwargs
240227
async def connect(self):
        
        self.pool = await aiopg.create_pool(
            loop=self.loop,
            timeout=self.timeout,
            database=self.database,
            **self.connect_params)
1106976
def connection_from_host(self, host, port=80, scheme='http'):
        
        pool_key = (scheme, host, port)

        # If the scheme, host, or port doesn't match existing open connections,
        # open a new ConnectionPool.
        pool = self.pools.get(pool_key)
        if pool:
            return pool

        # Make a fresh ConnectionPool of the desired type
        pool_cls = pool_classes_by_scheme[scheme]
        pool = pool_cls(host, port, **self.connection_pool_kw)

        self.pools[pool_key] = pool

        return pool