[issue34730] aclose() doesn't stop raise StopAsyncIteration / GeneratorExit to __anext__()

2018-09-19 Thread Devin Fee
Change by Devin Fee : -- versions: +Python 3.6 ___ Python tracker <https://bugs.python.org/issue34730> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue34730] aclose() doesn't stop raise StopAsyncIteration / GeneratorExit to __anext__()

2018-09-18 Thread Devin Fee
Devin Fee added the comment: 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() e

[issue34730] aclose() doesn't stop raise StopAsyncIteration / GeneratorExit to __anext__()

2018-09-18 Thread Devin Fee
New submission from Devin Fee : I expected an async-generator's aclose() method to cancel it's __anext__(). Instead, the task isn't cancelled, and (it seems) manually cleanup is necessary. @pytest.mark.asyncio async def test_aclose_cancels(): done = False event