@classmethod
def get_connection(cls, pid, connection):
    """Return the specified :class:`~queries.pool.Connection` from the
        pool.

        :param str pid: The pool ID
        :param connection: The connection to return for
        :type connection: psycopg2.extensions.connection
        :rtype: queries.pool.Connection

        """
    with cls._lock:
        return cls._pools[pid].connection_handle(connection)
