|  |  | @ -11,7 +11,7 @@ from rq import Worker | 
			
		
	
		
		
			
				
					
					|  |  |  | logger = logging.getLogger(__name__) |  |  |  | logger = logging.getLogger(__name__) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | def cleanup_ghosts(): |  |  |  | def cleanup_ghosts(conn=None): | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     """ |  |  |  |     """ | 
			
		
	
		
		
			
				
					
					|  |  |  |     RQ versions < 0.3.6 suffered from a race condition where workers, when |  |  |  |     RQ versions < 0.3.6 suffered from a race condition where workers, when | 
			
		
	
		
		
			
				
					
					|  |  |  |     abruptly terminated, did not have a chance to clean up their worker |  |  |  |     abruptly terminated, did not have a chance to clean up their worker | 
			
		
	
	
		
		
			
				
					|  |  | @ -21,8 +21,8 @@ def cleanup_ghosts(): | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     This function will clean up any of such legacy ghosted workers. |  |  |  |     This function will clean up any of such legacy ghosted workers. | 
			
		
	
		
		
			
				
					
					|  |  |  |     """ |  |  |  |     """ | 
			
		
	
		
		
			
				
					
					|  |  |  |     conn = get_current_connection() |  |  |  |     conn = conn if conn else get_current_connection() | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     for worker in Worker.all(): |  |  |  |     for worker in Worker.all(connection=conn): | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         if conn._ttl(worker.key) == -1: |  |  |  |         if conn._ttl(worker.key) == -1: | 
			
		
	
		
		
			
				
					
					|  |  |  |             ttl = worker.default_worker_ttl |  |  |  |             ttl = worker.default_worker_ttl | 
			
		
	
		
		
			
				
					
					|  |  |  |             conn.expire(worker.key, ttl) |  |  |  |             conn.expire(worker.key, ttl) | 
			
		
	
	
		
		
			
				
					|  |  | 
 |