Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 739580 - sys-apps/portage: reload of portage module triggers leak in multiprocessing.util._afterfork_registry
Summary: sys-apps/portage: reload of portage module triggers leak in multiprocessing.u...
Status: RESOLVED WORKSFORME
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All All
: Normal normal
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-08-30 00:01 UTC by Zac Medico
Modified: 2020-08-30 00:05 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zac Medico gentoo-dev 2020-08-30 00:01:18 UTC
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>)]
Comment 1 Zac Medico gentoo-dev 2020-08-30 00:05:10 UTC
Actually, it's not a problem, because gc.collect() really does delete the old _ForkWatcher.