File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Lib/test/test_free_threading Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ import unittest
2+ import sys
3+ from threading import Thread , Barrier
4+ from test .support import threading_helper
5+
6+ threading_helper .requires_working_threading (module = True )
7+
8+ class BytesThreading (unittest .TestCase ):
9+
10+ @threading_helper .reap_threads
11+ def test_conversion_from_list (self ):
12+ number_of_threads = 10
13+ number_of_iterations = 10
14+ barrier = Barrier (number_of_threads )
15+
16+ x = [1 , 2 , 3 , 4 , 5 ]
17+ e = [ (ii ,)* (2 + 4 * ii ) for ii in range (number_of_threads )] # range of sizes to extend
18+ def work (ii ):
19+ barrier .wait ()
20+ for _ in range (1000 ):
21+ bytes (x )
22+ x .extend (e [ii ])
23+ if len (x ) > 10 :
24+ x [:] = [0 ]
25+
26+ for it in range (number_of_iterations ):
27+ worker_threads = []
28+ for ii in range (number_of_threads ):
29+ worker_threads .append (
30+ Thread (target = work , args = [ii ]))
31+ with threading_helper .start_threads (worker_threads ):
32+ pass
33+
34+ barrier .reset ()
35+
36+ if __name__ == "__main__" :
37+ unittest .main ()
You can’t perform that action at this time.
0 commit comments