def decorate(func):

    def _handler(_, transaction):
        if (transaction.parent is None):
            func()
    sqlalchemy.event.listen(session, 'after_transaction_end', _handler)
    return func
def decorate(func):

    def _handler(_, transaction):
        if (transaction.parent is None):
            func()
    sqlalchemy.event.listen(session, 'after_transaction_end', _handler)
    return func