File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Lib/test/test_free_threading Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,35 @@ def mutate_set():
7171 for t in threads :
7272 t .join ()
7373
74+ def test_contains_frozenset (self ):
75+ barrier = Barrier (3 )
76+ done = False
77+
78+ NUM_ITEMS = 2_000
79+ NUM_LOOPS = 20
80+
81+ s = frozenset ()
82+ def make_set ():
83+ nonlocal s
84+ barrier .wait ()
85+ while not done :
86+ s = frozenset (range (NUM_ITEMS ))
87+
88+ def read_set ():
89+ nonlocal done
90+ barrier .wait ()
91+ for _ in range (NUM_LOOPS ):
92+ for i in range (NUM_ITEMS ):
93+ item = i >> 1
94+ result = item in s
95+ done = True
96+
97+ threads = [Thread (target = read_set ), Thread (target = read_set ), Thread (target = make_set )]
98+ for t in threads :
99+ t .start ()
100+ for t in threads :
101+ t .join ()
102+
74103
75104if __name__ == "__main__" :
76105 unittest .main ()
You can’t perform that action at this time.
0 commit comments