aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_code.py
diff options
context:
space:
mode:
authorSam Gross <colesbury@gmail.com>2024-04-29 14:36:02 -0400
committerGitHub <noreply@github.com>2024-04-29 14:36:02 -0400
commit7ccacb220d99662b626c8bc63b00a27eaf604f0c (patch)
tree231cb901ee62e523be237392b0f2b966aa8be128 /Lib/test/test_code.py
parent8d4b756fd31d4d91b55105b1241561e92cc571a3 (diff)
downloadcpython-7ccacb220d99662b626c8bc63b00a27eaf604f0c.tar.gz
cpython-7ccacb220d99662b626c8bc63b00a27eaf604f0c.zip
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.
Diffstat (limited to 'Lib/test/test_code.py')
-rw-r--r--Lib/test/test_code.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/test/test_code.py b/Lib/test/test_code.py
index fe8c672e71a..aa793f56225 100644
--- a/Lib/test/test_code.py
+++ b/Lib/test/test_code.py
@@ -141,7 +141,8 @@ except ImportError:
ctypes = None
from test.support import (cpython_only,
check_impl_detail, requires_debug_ranges,
- gc_collect, Py_GIL_DISABLED)
+ gc_collect, Py_GIL_DISABLED,
+ suppress_immortalization)
from test.support.script_helper import assert_python_ok
from test.support import threading_helper, import_helper
from test.support.bytecode_helper import instructions_with_positions
@@ -577,6 +578,7 @@ class CodeConstsTest(unittest.TestCase):
class CodeWeakRefTest(unittest.TestCase):
+ @suppress_immortalization()
def test_basic(self):
# Create a code object in a clean environment so that we know we have
# the only reference to it left.
@@ -827,6 +829,7 @@ if check_impl_detail(cpython=True) and ctypes is not None:
self.assertEqual(GetExtra(f.__code__, FREE_INDEX+100,
ctypes.c_voidp(100)), 0)
+ @suppress_immortalization()
def test_free_called(self):
# Verify that the provided free function gets invoked
# when the code object is cleaned up.
@@ -854,6 +857,7 @@ if check_impl_detail(cpython=True) and ctypes is not None:
del f
@threading_helper.requires_working_threading()
+ @suppress_immortalization()
def test_free_different_thread(self):
# Freeing a code object on a different thread then
# where the co_extra was set should be safe.