def METHOD_NAME(self, conn, key=None, close=False):
    """Put away a connection."""
    if self.closed:
        raise PoolError("connection pool is closed")
    if key is None:
        key = self._rused.get(id(conn))
        if key is None:
            raise PoolError("trying to put unkeyed connection")
    if len(self._pool) < self.minconn and not close:
        # Return the connection into a consistent state before putting
        # it back into the pool
        if not conn.closed:
            status = conn.info.transaction_status
            if status == _ext.TRANSACTION_STATUS_UNKNOWN:
                # server connection lost
                conn.close()
            elif status != _ext.TRANSACTION_STATUS_IDLE:
                # connection in error or in transaction
                conn.rollback()
                self._pool.append(conn)
            else:
                # regular idle connection
                self._pool.append(conn)
        # If the connection is closed, we just discard it.
    else:
        conn.close()
    # here we check for the presence of key because it can happen that a
    # thread tries to put back a connection after a call to close
    if not self.closed or key in self._used:
        del self._used[key]
        del self._rused[id(conn)]