[New-bugs-announce] [issue40986] Async generators are not garbage collected
report at bugs.python.org
Mon Jun 15 10:27:50 EDT 2020
New submission from Vytautas Liuolia <vytautas.liuolia at gmail.com>:
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.
nosy: asvetlov, vytas, yselivanov
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>
More information about the New-bugs-announce