[issue44518] Finalization of non-exhausted asynchronous generators is deferred

2021-06-28 Thread Guido van Rossum
Guido van Rossum added the comment: Okay, that suggests that the extra reference is being held by asyncio, right? I suppose it's in the hands of the asyncio devs then. -- ___ Python tracker

[issue44518] Finalization of non-exhausted asynchronous generators is deferred

2021-06-28 Thread Serhiy Storchaka
Serhiy Storchaka 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_asy

[issue44518] Finalization of non-exhausted asynchronous generators is deferred

2021-06-28 Thread Guido van Rossum
Guido van Rossum added the comment: I am wondering whether the issue is in asyncio.run, or in the basic async generator implementation. If the latter, you should be able to demonstrate this with a manual "driver" (trampoline?) instead of asyncio.run. -- _

[issue44518] Finalization of non-exhausted asynchronous generators is deferred

2021-06-27 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Sorry, I do not understand what do you mean. The problem is that non-exhausted asynchronous generators are not finalized until asyncio.run() is finished. This differs from synchronous generators which are finalized as early as possible (in CPython). -

[issue44518] Finalization of non-exhausted asynchronous generators is deferred

2021-06-27 Thread Guido van Rossum
Guido van Rossum added the comment: Can you repro this without asyncio? -- nosy: +Guido.van.Rossum ___ Python tracker ___ ___ Pytho

[issue44518] Finalization of non-exhausted asynchronous generators is deferred

2021-06-27 Thread Serhiy Storchaka
New submission from Serhiy Storchaka : In the following example: def gen(): try: yield 1 finally: print('finalize inner') def func(): try: for x in gen(): break finally: print('finalize outer') func() print('END') the output in CPyt