MCPcopy Create free account
hub / github.com/python/cpython / test_get_referrers

Method test_get_referrers

Lib/test/test_free_threading/test_gc.py:37–63  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

35 pass
36
37 def test_get_referrers(self):
38 NUM_GC = 2
39 NUM_MUTATORS = 4
40
41 b = threading.Barrier(NUM_GC + NUM_MUTATORS)
42 event = threading.Event()
43
44 obj = MyObj()
45
46 def gc_thread():
47 b.wait()
48 for i in range(100):
49 o = gc.get_referrers(obj)
50 event.set()
51
52 def mutator_thread():
53 b.wait()
54 while not event.is_set():
55 d1 = { "key": obj }
56 d2 = { "key": obj }
57 d3 = { "key": obj }
58 d4 = { "key": obj }
59
60 gcs = [Thread(target=gc_thread) for _ in range(NUM_GC)]
61 mutators = [Thread(target=mutator_thread) for _ in range(NUM_MUTATORS)]
62 with threading_helper.start_threads(gcs + mutators):
63 pass
64
65 def test_freeze_object_in_brc_queue(self):
66 # GH-142975: Freezing objects in the BRC queue could result in some

Callers

nothing calls this directly

Calls 4

ThreadClass · 0.90
BarrierMethod · 0.80
EventMethod · 0.80
MyObjClass · 0.70

Tested by

no test coverage detected