human
I wrote the below code

    def _commit_on_success(*args, **kw):
        try:
            enter_transaction_management()
            managed(True)
            try:
                res = func(*args, **kw)
            except Exception as e:
                if is_dirty():
                    rollback()
                raise
            else:
                if is_dirty():
                    commit()
            return res
        finally:
            leave_transaction_management()
    return _commit_on_success

What's a good function header?
assistant
#Here's a good function header.

def commit_on_success(func):