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 vytas
Recipients asvetlov, vytas, yselivanov
Date 2020-06-15.14:27:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1592231270.66.0.0853044039719.issue40986@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-06-15 14:27:50vytassetrecipients: + vytas, asvetlov, yselivanov
2020-06-15 14:27:50vytassetmessageid: <1592231270.66.0.0853044039719.issue40986@roundup.psfhosted.org>
2020-06-15 14:27:50vytaslinkissue40986 messages
2020-06-15 14:27:50vytascreate