summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_gc.py
diff options
context:
space:
mode:
authorbrainfvck <li.zekun@gmail.com>2017-10-16 19:49:41 (GMT)
committerƁukasz Langa <lukasz@langa.pl>2017-10-16 19:49:41 (GMT)
commitc75edabbb65ca2bb29e51f8d1eb2c780e5890982 (patch)
treee437dc1926002cf3700c39696ec239da3f31dc1e /Lib/test/test_gc.py
parentbdaeb7d237462a629e6c85001317faa85f94a0c6 (diff)
downloadcpython-c75edabbb65ca2bb29e51f8d1eb2c780e5890982.zip
cpython-c75edabbb65ca2bb29e51f8d1eb2c780e5890982.tar.gz
cpython-c75edabbb65ca2bb29e51f8d1eb2c780e5890982.tar.bz2
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.
Diffstat (limited to 'Lib/test/test_gc.py')
-rw-r--r--Lib/test/test_gc.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_gc.py b/Lib/test/test_gc.py
index 914efec..904fc7d 100644
--- a/Lib/test/test_gc.py
+++ b/Lib/test/test_gc.py
@@ -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):