This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author dfee
Recipients asvetlov, dfee, yselivanov
Date 2018-09-19.06:12:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1537337554.33.0.956365154283.issue34730@psf.upfronthosting.co.za>
In-reply-to
Content
I've worked around this problem by doing something like this:

async def close_cancelling(agen):
    while True:
        try:
            task = asyncio.ensure_future(agen.__anext__())
            await task
            yield task.result()
        except (GeneratorExit, StopAsyncIteration):
            await agen.aclose()
            task.cancel()
            break


async def run():
    try:
        async for v in close_cancelling(agen):
            received.append(v)
    except asyncio.CancelledError:
        # handle finalization
        pass

Though, I'm still convinced that `aclose()` should call raise `StopAsyncIteration` on `agen.ag_await`
History
Date User Action Args
2018-09-19 06:12:34dfeesetrecipients: + dfee, asvetlov, yselivanov
2018-09-19 06:12:34dfeesetmessageid: <1537337554.33.0.956365154283.issue34730@psf.upfronthosting.co.za>
2018-09-19 06:12:34dfeelinkissue34730 messages
2018-09-19 06:12:34dfeecreate