Yury Selivanov <yseliva...@gmail.com> added the comment:
Just discussed this issue off-list with Nathaniel. Maybe this isn't as severe as I thought it is. If we cancel all asyncio tasks before calling `loop.shutdown_asyncgens()` this *probably* becomes a non-issue. And "asyncio.run()" does just that [1]. Any asynchronous generator ultimately needs a task to iterate it, so if we cancel tasks, we should cancel all asynchronous generators too. Calling `loop.shutdown_asyncgens()` then ensures that there are no orphan async generators. The only way (at least known to me) that that could be the case if some tasks ignores cancellation. Nathaniel, what do you think about this in the context of Trio? If anything, we can update asyncio docs explaining the new behavior of async generators and how to use "loop.shutdown_asyncgens()". [1] https://github.com/python/cpython/blob/91528f40c30717563a478920861c81d18da5bf63/Lib/asyncio/runners.py#L46 ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue38559> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com