Nick Coghlan added the comment:

Latest version looks good to me (aside from a quibble about whether 
StopAsyncIteration should inherit from BaseException instead of Exception - see 
my review for details).

Based on Guido's explanation in the review, I also suggested adding the 
following example method to the PEP as part of the rationale for 
StopAsyncIteration:

    def __anext__(self):
        try:
            data = await self._get_data()
        except EOFError:
            raise StopAsyncIteration
        return data

The trick is that when __anext__ is itself a coroutine, we really do have 3 
exit paths:

* suspension to wait for events (await)
* returning the next value (return)
* terminating iteration (raise StopAsyncIteration)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24017>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to