'End a context.
-  If there was no exception, commit up to the current high-water mark.
-  If there was an offset of range error, attempt to find the correct
initial offset.
-  If there was any other error, roll back to the initial offsets.'

def __exit__(self, exc_type, exc_value, traceback):

    if (exc_type is None):
        self.commit()
    elif isinstance(exc_value, OffsetOutOfRangeError):
        self.handle_out_of_range()
        return True
    else:
        self.rollback()
