[New-bugs-announce] [issue40986] Async generators are not garbage collected

Vytautas Liuolia report at bugs.python.org
Mon Jun 15 10:27:50 EDT 2020


New submission from Vytautas Liuolia <vytautas.liuolia at gmail.com>:

Hello!
I am having issues with asynchronous generators not being garbage collected at least until the current loop has completed.

In the attached test case (test.py), one starts iterating over an asynchronous generator, then breaks and returns the first element. After each call, gc.collect() is invoked for illustration purposes.
It seems that no memory is freed until the whole test() coroutine is done.

The for-loop could obviously be extended to more iterations, or swapped out to a while-loop to easily run out of available memory.

I have then removed all async stuff, producing test_sync.py (also attached). In the sync case, everything is garbage-collected as I would expect.

----------
components: asyncio
files: test.py
messages: 371550
nosy: asvetlov, vytas, yselivanov
priority: normal
severity: normal
status: open
title: Async generators are not garbage collected
type: resource usage
versions: Python 3.8
Added file: https://bugs.python.org/file49231/test.py

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


More information about the New-bugs-announce mailing list