bpo-26180: Fix multiple registration of ForkAwareLocal atfork cleaner#13986
bpo-26180: Fix multiple registration of ForkAwareLocal atfork cleaner#13986orivej wants to merge 3 commits into
Conversation
`threading.local` instance `__init__` method is called multiple times, once per thread where the instance is used, but ForkAwareLocal atfork handler needs to be registered just once when its instance is created. If it is registered many times, the registrations bloat `_afterfork_registry` as long as the instance is alive, and can exhaust all memory.
|
A test for the change would be awesome |
|
I have added a test |
|
Added a NEWS blurb. Feel free to edit or squash commits as you see fit. |
jdemeyer
left a comment
There was a problem hiding this comment.
The change and test look good to me. The only thing that I'm not sure about is whether this is the best fix for the problem: as I mentioned on bpo-26810 I wonder if we could ensure that __init__ is not called multiple times.
|
|
|
OK, you convinced me. |
|
What shall happen next? |
|
We need a core developer to review your PR. |
|
Monthly ping. |
|
This PR is stale because it has been open for 30 days with no activity. |
threading.localinstance__init__method is called multiple times, once perthread where the instance is used, but ForkAwareLocal atfork handler needs to be
registered just once when its instance is created. If it is registered many
times, the registrations bloat
_afterfork_registryas long as the instance isalive, and can exhaust all memory.
https://bugs.python.org/issue26180