File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 1414 import_helper ,
1515 Py_GIL_DISABLED ,
1616 requires_jit_enabled ,
17+ threading_helper ,
1718 reset_code
1819)
1920
@@ -462,6 +463,35 @@ def testfunc(n, m):
462463 self .assertIn ("_FOR_ITER_TIER_TWO" , uops )
463464
464465
466+ @requires_jit_enabled
467+ @threading_helper .requires_working_threading ()
468+ @unittest .skipIf (not Py_GIL_DISABLED , "Requires FT and JIT" )
469+ class TestJitFreeThreading (unittest .TestCase ):
470+ def tests_reenabled_with_multiple_threads (self ):
471+ import threading
472+ def testfunc (x , expected_value ):
473+ for i in range (x ):
474+ pass
475+
476+ ex = get_first_executor (testfunc )
477+ self .assertIsNone (ex )
478+ # JIT
479+ testfunc (TIER2_THRESHOLD + 1 , True )
480+ ex = get_first_executor (testfunc )
481+ self .assertIsNotNone (ex )
482+ # Spawn threads (turn off the JIT).
483+ t = threading .Thread (target = lambda :None , args = ())
484+ t .start ()
485+ t .join ()
486+ # JIT is invalidated after spawning threads.
487+ ex = get_first_executor (testfunc )
488+ self .assertIsNone (ex )
489+ # JIT.
490+ testfunc (TIER2_THRESHOLD + 1 , True )
491+ ex = get_first_executor (testfunc )
492+ self .assertIsNotNone (ex )
493+
494+
465495@requires_jit_enabled
466496@unittest .skipIf (os .getenv ("PYTHON_UOPS_OPTIMIZE" ) == "0" , "Needs uop optimizer to run." )
467497class TestUopsOptimization (unittest .TestCase ):
You can’t perform that action at this time.
0 commit comments