Since _ForkWatcher.hook references _ForkWatcher via a staticmethod decorator, it prevents garbage collection of _ForkWatcher when the portage module is reloaded: > Python 3.8.3 (default, Jul 6 2020, 20:21:42) > [GCC 9.2.0] on linux > Type "help", "copyright", "credits" or "license" for more information. > >>> import portage > >>> import multiprocessing.util > >>> list(multiprocessing.util._afterfork_registry) > [(0, 94809952799472, <function _ForkWatcher.hook at 0x7f055034b550>)] > >>> from importlib import reload > >>> reload(portage) > <module 'portage' from '/usr/lib/python3.8/site-packages/portage/__init__.py'> > >>> list(multiprocessing.util._afterfork_registry) > [(0, 94809952799472, <function _ForkWatcher.hook at 0x7f055034b550>), (1, 94809952837968, <function _ForkWatcher.hook at 0x7f055024f8b0>)]
Actually, it's not a problem, because gc.collect() really does delete the old _ForkWatcher.