[issue40986] Async generators are not garbage collected

Vytautas Liuolia report at bugs.python.org
Wed Jun 24 16:13:32 EDT 2020


Vytautas Liuolia <vytautas.liuolia at gmail.com> added the comment:

I've now skimmed through the relevant Trio issue https://github.com/python-trio/trio/issues/265 and the currently deferred https://www.python.org/dev/peps/pep-0533/ and, as I understand, the issue is not trivial and subject to subtle edge cases.

Getting back to the issue, it looks like a misunderstanding on my side, sorry!

As per PEP-525:

    The asyncio event loop will use sys.set_asyncgen_hooks() API to maintain a weak set of all scheduled asynchronous generators, and to schedule their aclose() coroutine methods when it is time for generators to be GCed.

It seems that my original test case just doesn't give these aclose() coroutines a chance to run. Awaiting an asyncio.sleep() "fixes" that.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40986>
_______________________________________


More information about the Python-bugs-list mailing list