Yury Selivanov added the comment:
> 1. In PEP525 the documentation for aclose() is a bit terse and unclear to me.
> It appeared to suggest that you could catch GeneratorExit and yield, but I
> found this to result in a RuntimeError like a normal generator. I tried to
> document this as it actually behaves.
Yes, it should result in a RuntimeError. What PEP 525 is trying to explain is
that it's OK to do this (although 'finally' is better):
async def gen():
try:
yield
except GeneratorExit:
await smth()
# using 'yield' here will trigger a RuntimeError
raise
> 2. One thing that I noticed documented about normal generators is that they
> raise a ValueError if you try to run send() while another send() call is
> currently running. I verified this using threads. I looked into corresponding
> behavior for asynchronous generators, calling asend(), running the awaitable
> halfway through, and then calling asend() again to get a second awaitable
> before the first one finished. Asyncio seems to prevent more than one
> awaitable from a single async generator running at the same time, but I
> couldn't figure out how. Running some coroutines "by hand" calling asend()
> and send(), I was permitted to run multiple awaitables concurrently which
> produced odd results.
Interesting. This is something that has to be fixed (in 3.6.1)
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue28091>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com