mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
bpo-31558: Add gc.freeze() (#3705)
Freeze all the objects tracked by gc - move them to a permanent generation and ignore all the future collections. This can be used before a POSIX fork() call to make the gc copy-on-write friendly or to speed up collection.
This commit is contained in:
parent
bdaeb7d237
commit
c75edabbb6
5 changed files with 169 additions and 2 deletions
|
@ -734,6 +734,12 @@ class GCTests(unittest.TestCase):
|
|||
self.assertEqual(new[1]["collections"], old[1]["collections"])
|
||||
self.assertEqual(new[2]["collections"], old[2]["collections"] + 1)
|
||||
|
||||
def test_freeze(self):
|
||||
gc.freeze()
|
||||
self.assertGreater(gc.get_freeze_count(), 0)
|
||||
gc.unfreeze()
|
||||
self.assertEqual(gc.get_freeze_count(), 0)
|
||||
|
||||
|
||||
class GCCallbackTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue