Skip to content

Commit c5884fc

Browse files
committed
Finish cleaning up
1 parent 289642f commit c5884fc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

main.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ def save(results, checkpoint):
9595
break
9696
except PermissionError:
9797
time.sleep(0.01)
98-
98+
else:
99+
print("Warning: Could not save results due to persistent PermissionError.")
100+
99101
with open(checkpointPath + '.tmp', 'wb') as file:
100102
pickle.dump(checkpoint, file)
101103
for _ in range(20):
@@ -104,6 +106,8 @@ def save(results, checkpoint):
104106
break
105107
except PermissionError:
106108
time.sleep(0.01)
109+
else:
110+
print("Warning: Could not save checkpoint due to persistent PermissionError.")
107111

108112
def loadResults():
109113
if os.path.exists(resultsPath):
@@ -179,7 +183,7 @@ def simulatePrisoners():
179183
for prisoner in prisoners:
180184
results[-1]["prisoners"].append({"found": prisoners[prisoner][1], "checked_boxes": prisoners[prisoner][0]})
181185

182-
saving.save(results, {"last_simulation": sim, "rng_state": rng.getstate()})
186+
saving.save(results, {"last_simulation": sim, "rng_state": rng.getstate()})
183187
print("All simulations completed.")
184188

185189
if __name__ == "__main__":

0 commit comments

Comments
 (0)