mirror of
https://github.com/Brandon-Rozek/matmod.git
synced 2025-07-29 20:52:01 +00:00
Adding more work to task queue and more detailed healthcheck
This commit is contained in:
parent
502252676f
commit
806309b1ae
1 changed files with 11 additions and 3 deletions
14
vspursuer.py
14
vspursuer.py
|
@ -121,8 +121,10 @@ if __name__ == "__main__":
|
||||||
p.start()
|
p.start()
|
||||||
|
|
||||||
# Populate initial task queue
|
# Populate initial task queue
|
||||||
|
# NOTE: Adding more than number of processes
|
||||||
|
# to make sure there's always work to do.
|
||||||
done_parsing = False
|
done_parsing = False
|
||||||
for _ in range(num_cpu):
|
for _ in range(num_cpu * 2):
|
||||||
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
|
||||||
|
@ -137,9 +139,15 @@ if __name__ == "__main__":
|
||||||
result = result_queue.get(True, 60)
|
result = result_queue.get(True, 60)
|
||||||
except QueueEmpty:
|
except QueueEmpty:
|
||||||
# Health check in case processes crashed
|
# Health check in case processes crashed
|
||||||
if all((not p.is_alive() for p in processes)):
|
num_dead = 0
|
||||||
print("[WARNING] No child processes remain")
|
for p in processes:
|
||||||
|
if not p.is_alive():
|
||||||
|
num_dead += 1
|
||||||
|
if num_dead == len(processes):
|
||||||
|
print("[ERROR] No child processes remain")
|
||||||
break
|
break
|
||||||
|
elif num_dead > 0:
|
||||||
|
print("[WARNING] Number of dead processes:", num_dead)
|
||||||
# Otherwise continue
|
# Otherwise continue
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue