def transaction_guard(f):
    @functools.wraps(f)
    def inner(self, context, *args, **kwargs):
        if context.session.is_active:
            raise RuntimeError(_("Method cannot be called within a "
                                 "transaction."))
        return f(self, context, *args, **kwargs)
    return inner
Ensures that the context passed in is not in a transaction.
dataset/ETHPy150Open openstack/neutron/neutron/common/utils.py/transaction_guard