File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Lib/test/test_free_threading Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -148,6 +148,32 @@ def read_set():
148148 for t in threads :
149149 t .join ()
150150
151+ def test_iter_length_hint_mutate (self ):
152+ s = set (range (2000 ))
153+ it = iter (s )
154+ stop = Event ()
155+
156+ def reader ():
157+ while not stop .is_set ():
158+ it .__length_hint__ ()
159+
160+ def writer ():
161+ i = 0
162+ while not stop .is_set ():
163+ s .add (i )
164+ s .discard (i - 1 )
165+ i += 1
166+
167+ threads = [Thread (target = reader ) for _ in range (4 )]
168+ threads .append (Thread (target = writer ))
169+
170+ for t in threads :
171+ t .start ()
172+
173+ stop .set ()
174+
175+ for t in threads :
176+ t .join ()
151177
152178@threading_helper .requires_working_threading ()
153179class SmallSetTest (RaceTestBase , unittest .TestCase ):
You can’t perform that action at this time.
0 commit comments