The EbuildBuild._fetchonly_exit method triggers event loop recursion when it calls the spawn_nofetch function. There spawn_nofetch function needs to be refactored into an asynchronous task.
The EbuildBuild._fetchonly_exit method can also call digestgen, which can trigger event loop recursion via portdbapi.aux_get and spawn_nofetch calls.
We can move the digestgen call from EbuildBuild._fetchonly_exit (bug 470238) to Scheduler._generate_digests (where it currently skips the digestgen call when --fetchonly is enabled).
Patches posted for review: https://archives.gentoo.org/gentoo-portage-dev/message/f0817238440cef52389f0a95e22368af https://github.com/gentoo/portage/pull/154
This is in the master branch: https://gitweb.gentoo.org/proj/portage.git/commit/?id=f05d0864653e082bd60db67b52132c4ba6515339 https://gitweb.gentoo.org/proj/portage.git/commit/?id=285d5d038d8bb8a17d853816e156147c8c59f248
Fixed in 2.3.6.