def __next__(self):
next = self.endpoint()<EOL>if next is not None:<EOL><INDENT>return next<EOL><DEDENT>raise StopIteration<EOL>
Iterator function for Python 3.

        :returns: the next message in the sequence
        :raises StopIteration: if there are no more messages