Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
_wrap_loop: Prevent redundant AsyncioEventLoop instances
Use _safe_loop(create=False) to look up the AsyncioEventLoop instance associated with the current thread, and avoid creating redundant instances. This serves to guard against garbage collection of AsyncioEventLoop instances which many have _coroutine_exithandlers added by the run_exitfuncs function since commit cb0c09d from bug 937740. If _safe_loop(create=False) fails to associate a loop with the current thread, raise an AssertionError for portage internal API consumers. It's not known whether exernal API consumers will trigger this case, so if it happens then emit a UserWarning and return a temporary AsyncioEventLoop instance. Fixes: cb0c09d ("Support coroutine exitfuncs for non-main loops") Bug: https://bugs.gentoo.org/938127 Bug: https://bugs.gentoo.org/937740 Signed-off-by: Zac Medico <zmedico@gentoo.org>
- Loading branch information