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 serhiy.storchaka
Recipients Guido.van.Rossum, Mark.Shannon, asvetlov, gvanrossum, serhiy.storchaka, yselivanov
Date 2021-06-28.16:40:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1624898446.12.0.686803311056.issue44518@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2021-06-28 16:40:46serhiy.storchakasetrecipients: + serhiy.storchaka, gvanrossum, asvetlov, Mark.Shannon, yselivanov, Guido.van.Rossum
2021-06-28 16:40:46serhiy.storchakasetmessageid: <1624898446.12.0.686803311056.issue44518@roundup.psfhosted.org>
2021-06-28 16:40:46serhiy.storchakalinkissue44518 messages
2021-06-28 16:40:46serhiy.storchakacreate