'Leaves transaction management for a running thread. A dirty flag is carried
over to the surrounding block, as a commit will commit all changes, even
those from outside. (Commits are on connection level.)'

def leave_transaction_management(self):

    self._leave_transaction_management(self.is_managed())
    if self.transaction_state:
        del self.transaction_state[(-1)]
    else:
        raise TransactionManagementError("This    code    isn't    under    transaction    management")
    if self._dirty:
        self.rollback()
        raise TransactionManagementError('Transaction    managed    block    ended    with    pending    COMMIT/ROLLBACK')
    self._dirty = False
