Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:
Inlined asyncio.run(func()) is roughly equivalent to the following code: loop = asyncio.new_event_loop() loop.run_until_complete(func()) loop.run_until_complete(loop.shutdown_asyncgens()) loop.close() If comment out loop.run_until_complete(loop.shutdown_asyncgens()) I get the following output: finalize outer Task was destroyed but it is pending! task: <Task pending name='Task-2' coro=<<async_generator_athrow without __name__>()>> END No "finalize inner" but a warning about pending task instead. On other hand, the following code for _ in func().__await__(): pass produces the output in expected order: finalize inner finalize outer END ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44518> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com