File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -1064,6 +1064,8 @@ def flush(self):
10641064
10651065    @threading_helper .requires_working_threading () 
10661066    def  test_write_readline_races (self ):
1067+ 
1068+         # gh-134908: Concurrent iteration over a file caused races 
10671069        thread_count  =  2 
10681070        write_count  =  100 
10691071
@@ -1075,19 +1077,21 @@ def writer(file, barrier):
10751077        def  reader (file , stopping ):
10761078            while  not  stopping .is_set ():
10771079                for  line  in  file :
1078-                     assert   line   ==   "" 
1080+                     self . assertEqual ( line ,  "" ) 
10791081
10801082        stopping  =  threading .Event ()
10811083        with  self .open (os_helper .TESTFN , "w+" ) as  f :
10821084            barrier  =  threading .Barrier (thread_count )
10831085            reader  =  threading .Thread (target = reader , args = (f , stopping ))
10841086            writers  =  [threading .Thread (target = writer , args = (f , barrier ))
10851087                       for  _  in  range (thread_count )]
1086-             reader .start ()
1087-             with  threading_helper .start_threads (writers ):
1088-                 pass 
1089-             stopping .set ()
1090-             reader .join ()
1088+             with  threading_helper .catch_threading_exception () as  cm :
1089+                 reader .start ()
1090+                 with  threading_helper .start_threads (writers ):
1091+                     pass 
1092+                 stopping .set ()
1093+                 reader .join ()
1094+                 self .assertIsNone (cm .exc_type )
10911095
10921096        self .assertEqual (os .stat (os_helper .TESTFN ).st_size ,
10931097                         write_count  *  thread_count )
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments