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

2020-08-20 Thread Dima Tisnek
Dima Tisnek added the comment: Then perhaps the issue should be closed 樂 -- ___ Python tracker ___ ___ Python-bugs-list mailing

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

2020-08-20 Thread Nathaniel Smith
Nathaniel Smith added the comment: > Perhaps it's time to restart the original discussion, whether `aclose()` > should cancel pending `anext`. I'm still not aware of any way to make this work, technically. So it's a moot point unless someone has a proposal. --

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

2020-08-20 Thread Dima Tisnek
Dima Tisnek added the comment: https://github.com/python/cpython/pull/7468 (prohibit asend/etc. reentrance) was merged ~a year ago. Perhaps it's time to restart the original discussion, whether `aclose()` should cancel pending `anext`. -- nosy: +Dima.Tisnek versions: +Python 3.10

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

2018-09-20 Thread Christoph Zwerschke
Change by Christoph Zwerschke : -- nosy: +cito ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

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

2018-09-20 Thread Yury Selivanov
Yury Selivanov added the comment: > So I think we just need to fix ag_running and then recommend people find > other ways to interrupt running async generators. Agree. Speaking of fixing ag_running, could you please review my PR: https://github.com/python/cpython/pull/7468 I can then commit

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

2018-09-20 Thread Nathaniel Smith
Nathaniel Smith added the comment: Part of the issue here is the one discussed in bpo-30773 / bpo-32526: async generators allow themselves to be re-entered while another asend/athrow/aclose call is in progress, and it causes weird and confusing results. So at a minimum, trying to call

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

2018-09-20 Thread Yury Selivanov
Yury Selivanov added the comment: Interesting. Nathaniel, do you have this problem in Trio (aclose() not cancelling an anext()) or cancel scopes solve this problem somehow? -- nosy: +njs ___ Python tracker

[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 ___ ___ Python-bugs-list mailing list Unsubscribe:

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

2018-09-19 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() except

[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 = asyncio.Event()