Nathaniel Smith <n...@pobox.com> added the comment:

Huh, this is very weird. I can confirm that the async generator objects aren't 
cleaned up until loop shutdown on asyncio.

On the trio main branch, we don't yet use the `set_asyncgen_hooks` mechanism, 
and the async generator objects are cleaned up immediately.

However, if I check out this PR that will add it: 
https://github.com/python-trio/trio/pull/1564

...then we see the same bug happening with Trio: all the async generators are 
kept around until loop shutdown.

Also, it doesn't seem to be a circular references issue – if I explicitly call 
`gc.collect()`, then the asyncgen destructors are still *not* called; only 
shutting down the loop does it.

This doesn't make any sense, because asyncio/trio only keep weak references to 
the async generator objects, so they should still be freed.

So maybe the `set_asyncgen_hooks` code introduces a reference leak on async 
generator objects, or something?

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue41229>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to