def _take_cnx(self, connector, kwargs, key, tid):
        # Second best option: Reuse a live pooled connection
        if key in self._pool_key:
            idx = self._pool_key.index(key)
            self._pool_key.pop(idx)
            self._pool_time.pop(idx)
            cnx = self._pool.pop(idx)
            # If possible, verify that the pooled connection is
            # still available and working.
            if hasattr(cnx, 'ping'):
                return ('ping', cnx)
            return cnx
        # Third best option: Create a new connection
        elif len(self._active) + len(self._pool) < self._maxsize:
            return ('create', None)
        # Forth best option: Replace a pooled connection with a new one
        elif len(self._active) < self._maxsize:
            # Remove the LRU connection in the pool
            cnx = self._pool.pop(0)
            self._pool_key.pop(0)
            self._pool_time.pop(0)
            return ('close', cnx)
Command line interface for the ``rotate-backups`` program.
dataset/ETHPy150Open edgewall/trac/trac/db/pool.py/ConnectionPoolBackend._take_cnx--crossover with--dataset/ETHPy150Open xolox/python-rotate-backups/rotate_backups/cli.py/main