File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -224,8 +224,16 @@ def self.perform(job)
224224                  jid : 'jid' ,  retries : 10 ) 
225225        run_jobs ( worker ,  1 )  do 
226226          redis . brpop ( key ,  timeout : 1 ) . should  eq ( [ key . to_s ,  'foo' ] ) 
227-           # FIXME: this seems to get into infinite loop sometimes 
228-           until  client . jobs [ 'jid' ] . state  == 'waiting' ;  end 
227+           # Wait for job to transition to 'waiting' state with timeout protection 
228+           max_attempts  =  500   # 5 seconds with 10ms intervals 
229+           attempts  =  0 
230+           until  client . jobs [ 'jid' ] . state  == 'waiting' 
231+             attempts  += 1 
232+             if  attempts  > max_attempts 
233+               raise  "Job never reached 'waiting' state. Current state: #{ client . jobs [ 'jid' ] . state }  
234+             end 
235+             sleep  0.01 
236+           end 
229237        end 
230238        expect ( client . jobs [ 'jid' ] . retries_left ) . to  be  < 10 
231239      end 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments