This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients pitrou, serhiy.storchaka, vstinner
Date 2017-06-08.12:35:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1496925321.07.0.638576908343.issue30599@psf.upfronthosting.co.za>
In-reply-to
Content
> 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.
History
Date User Action Args
2017-06-08 12:35:21vstinnersetrecipients: + vstinner, pitrou, serhiy.storchaka
2017-06-08 12:35:21vstinnersetmessageid: <1496925321.07.0.638576908343.issue30599@psf.upfronthosting.co.za>
2017-06-08 12:35:21vstinnerlinkissue30599 messages
2017-06-08 12:35:20vstinnercreate