STINNER Victor added the comment:

> The leak was introduced by the commit 
> 346cbd351ee0dd3ab9cb9f0e4cb625556707877e.

This commit "bpo-16500: Allow registering at-fork handlers" adds the following 
code to Lib/random.py:

+if hasattr(_os, "fork"):
+    _os.register_at_fork(_inst.seed, when='child')

test_threaded_import creates fresh instance of the random module and so 
os.register_at_fork() is called multiple time with multiple different callbacks.

The problem is that it's not currently possible to remove callbacks. It would 
be nice to be able to unregister callbacks, at least a private for unit tests.

The minimum would be a os.unregister_at_fork() function.

I would prefer to have get/set functions to be able to restore callbacks once 
tests complete, but also to detect when an unexpected callback was registered. 
For example, write a new test in Lib/test/libregrtest/save_env.py for regrtest.

See also bpo-16500 which added the new API.

----------
nosy: +pitrou, serhiy.storchaka

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue30599>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to