From 7ccacb220d99662b626c8bc63b00a27eaf604f0c Mon Sep 17 00:00:00 2001 From: Sam Gross Date: Mon, 29 Apr 2024 14:36:02 -0400 Subject: gh-117783: Immortalize objects that use deferred reference counting (#118112) Deferred reference counting is not fully implemented yet. As a temporary measure, we immortalize objects that would use deferred reference counting to avoid multi-threaded scaling bottlenecks. This is only performed in the free-threaded build once the first non-main thread is started. Additionally, some tests, including refleak tests, suppress this behavior. --- Lib/test/test_weakref.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Lib/test/test_weakref.py') diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py index a2f5b9b2902..df90647baee 100644 --- a/Lib/test/test_weakref.py +++ b/Lib/test/test_weakref.py @@ -13,7 +13,7 @@ import random import textwrap from test import support -from test.support import script_helper, ALWAYS_EQ +from test.support import script_helper, ALWAYS_EQ, suppress_immortalization from test.support import gc_collect from test.support import import_helper from test.support import threading_helper @@ -651,6 +651,7 @@ class ReferencesTestCase(TestBase): # deallocation of c2. del c2 + @suppress_immortalization() def test_callback_in_cycle(self): import gc @@ -743,6 +744,7 @@ class ReferencesTestCase(TestBase): del c1, c2, C, D gc.collect() + @suppress_immortalization() def test_callback_in_cycle_resurrection(self): import gc @@ -878,6 +880,7 @@ class ReferencesTestCase(TestBase): # No exception should be raised here gc.collect() + @suppress_immortalization() def test_classes(self): # Check that classes are weakrefable. class A(object): -- cgit v1.2.3