def METHOD_NAME(table):
    """Temporarily disable autocommit and commit at the end.
    If an exception occurs, changes are rolled back.
    By default, changes to iptables rules are applied immediately. In some
    cases, we want to avoid that.
    https://github.com/ldx/python-iptables#autocommit
    """
    assert table.autocommit is True, table.autocommit
    try:
        table.autocommit = False
        yield
        table.commit()
    finally:
        table.refresh()
        table.autocommit = True