Summary: | sys-apps/portage: reload of portage module triggers leak in multiprocessing.util._afterfork_registry | ||
---|---|---|---|
Product: | Portage Development | Reporter: | Zac Medico <zmedico> |
Component: | Core | Assignee: | Portage team <dev-portage> |
Status: | RESOLVED WORKSFORME | ||
Severity: | normal | ||
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | All | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- |
Actually, it's not a problem, because gc.collect() really does delete the old _ForkWatcher. |
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>)]