MCPcopy Index your code
hub / github.com/python/cpython / test_code_attrs

Method test_code_attrs

Lib/test/test_free_threading/test_code.py:42–58  ·  view source on GitHub ↗

Test concurrent accesses to lazily initialized code attributes

(self)

Source from the content-addressed store, hash-verified

40@threading_helper.requires_working_threading()
41class TestCode(TestCase):
42 def test_code_attrs(self):
43 """Test concurrent accesses to lazily initialized code attributes"""
44 code_objects = []
45 for _ in range(1000):
46 code_objects.append(compile("a + b", "<string>", "eval"))
47
48 def run_in_thread():
49 for code in code_objects:
50 self.assertIsInstance(code.co_code, bytes)
51 self.assertIsInstance(code.co_freevars, tuple)
52 self.assertIsInstance(code.co_varnames, tuple)
53
54 threads = [Thread(target=run_in_thread) for _ in range(2)]
55 for thread in threads:
56 thread.start()
57 for thread in threads:
58 thread.join()
59
60 @unittest.skipUnless(ctypes, "ctypes is required")
61 def test_request_code_extra_index_concurrent(self):

Callers

nothing calls this directly

Calls 5

ThreadClass · 0.90
compileFunction · 0.50
appendMethod · 0.45
startMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected