mirror of
				https://github.com/Brandon-Rozek/matmod.git
				synced 2025-11-03 03:11:12 +00:00 
			
		
		
		
	Attempt at keeping workers busy
This commit is contained in:
		
							parent
							
								
									806309b1ae
								
							
						
					
					
						commit
						cb00a82c67
					
				
					 1 changed files with 18 additions and 4 deletions
				
			
		
							
								
								
									
										16
									
								
								vspursuer.py
									
										
									
									
									
								
							
							
						
						
									
										16
									
								
								vspursuer.py
									
										
									
									
									
								
							| 
						 | 
					@ -174,10 +174,24 @@ if __name__ == "__main__":
 | 
				
			||||||
        if done_parsing:
 | 
					        if done_parsing:
 | 
				
			||||||
            continue
 | 
					            continue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # NOTE: We should attempt to maintain a decent amount
 | 
				
			||||||
 | 
					        # of work in the task queue so that workers stay busy
 | 
				
			||||||
 | 
					        task_queue_size: Optional[int] = None
 | 
				
			||||||
 | 
					        try:
 | 
				
			||||||
 | 
					            task_queue_size = task_queue.qsize()
 | 
				
			||||||
 | 
					        except NotImplementedError:
 | 
				
			||||||
 | 
					            # On MacOS this isn't implemented
 | 
				
			||||||
 | 
					            pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        num_new_tasks = 1
 | 
				
			||||||
 | 
					        if task_queue_size is not None and task_queue_size < num_cpu * 2:
 | 
				
			||||||
 | 
					            num_new_tasks = (num_cpu * 2) - task_queue_size
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for _ in range(num_new_tasks):
 | 
				
			||||||
            added = add_to_queue(solutions, task_queue, num_cpu)
 | 
					            added = add_to_queue(solutions, task_queue, num_cpu)
 | 
				
			||||||
            if not added:
 | 
					            if not added:
 | 
				
			||||||
                done_parsing = True
 | 
					                done_parsing = True
 | 
				
			||||||
 | 
					                break
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    print(f"Tested {num_tested} models, {num_has_vsp} of which satisfy VSP")
 | 
					    print(f"Tested {num_tested} models, {num_has_vsp} of which satisfy VSP")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue