File tree Expand file tree Collapse file tree
Lib/test/test_free_threading Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import threading
2- import unittest
3-
4- from concurrent .futures import ThreadPoolExecutor
5- from threading import Barrier , Thread
6- from unittest import TestCase
7- import sys
8- from test .support import import_helper , threading_helper , Py_GIL_DISABLED
9-
10- _testinternalcapi = import_helper .import_module ("_testinternalcapi" )
11-
12-
13-
14- NTHREADS = 6
15- BOTTOM = 0
16- TOP = 1000
17- ITERS = 100
18-
19- class A :
20- attr = 1
21-
22- @threading_helper .requires_working_threading ()
23- class TestType (TestCase ):
24- def test_attr_cache (self ):
25- def read (id0 ):
26- for _ in range (ITERS ):
27- for _ in range (BOTTOM , TOP ):
28- A .attr
29-
30- def write (id0 ):
31- for _ in range (ITERS ):
32- for _ in range (BOTTOM , TOP ):
33- # Make _PyType_Lookup cache hot first
34- A .attr
35- A .attr
36- x = A .attr
37- x += 1
38- A .attr = x
39-
40-
41- with ThreadPoolExecutor (NTHREADS ) as pool :
42- pool .submit (read , (1 ,))
43- pool .submit (write , (1 ,))
44- pool .shutdown (wait = True )
1+ @file :// / tmp / to_push .py
You can’t perform that action at this time.
0 commit comments