mirror of
https://github.com/Brandon-Rozek/matmod.git
synced 2025-07-29 20:52:01 +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
22
vspursuer.py
22
vspursuer.py
|
@ -139,7 +139,7 @@ if __name__ == "__main__":
|
|||
result = result_queue.get(True, 60)
|
||||
except QueueEmpty:
|
||||
# Health check in case processes crashed
|
||||
num_dead = 0
|
||||
num_dead = 0
|
||||
for p in processes:
|
||||
if not p.is_alive():
|
||||
num_dead += 1
|
||||
|
@ -174,10 +174,24 @@ if __name__ == "__main__":
|
|||
if done_parsing:
|
||||
continue
|
||||
|
||||
added = add_to_queue(solutions, task_queue, num_cpu)
|
||||
if not added:
|
||||
done_parsing = True
|
||||
# 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)
|
||||
if not added:
|
||||
done_parsing = True
|
||||
break
|
||||
|
||||
print(f"Tested {num_tested} models, {num_has_vsp} of which satisfy VSP")
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue