[issue34769] _asyncgen_finalizer_hook running in wrong thread

twisteroid ambassador report at bugs.python.org
Mon Oct 1 11:33:11 EDT 2018


twisteroid ambassador <twisteroid.ambassador at gmail.com> added the comment:

I have finally managed to reproduce this one reliably. The issue happens when i) async generators are not finalized immediately and must be garbage collected in the future, and ii) the garbage collector happens to run in a different thread than the one running the event loop. (Obviously, if there are more than one Python threads, eventually gc will run in those other threads, causing problems.)

I have attached a script reproducing the problem. I tried several ways of using async generators (the use_agen_*() coroutines), and the only way to make them not finalize immediately is use_agen_anext_separate_tasks(), which is the pattern used in my Happy Eyeballs library.

----------
Added file: https://bugs.python.org/file47838/asyncgen_test.py

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


More information about the Python-bugs-list mailing list