'Close this :class:`.Transaction`.
If this transaction is the base transaction in a begin/commit
nesting, the transaction will rollback().  Otherwise, the
method returns.
This is used to cancel a Transaction without affecting the scope of
an enclosing transaction.'

def close(self):

    if (not self._parent.is_active):
        return
    if (self._parent is self):
        self.rollback()
