Skip to content

Commit

Permalink
Eliminate benign race condition.
Browse files Browse the repository at this point in the history
  • Loading branch information
vdbergh authored and ppigazzini committed Jan 25, 2025
1 parent 63cf725 commit c3e8210
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions server/fishtest/rundb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1628,13 +1628,14 @@ def approve_run(self, run_id, approver):
if run["args"]["username"] == approver:
return None, f"Run {str(run_id)}: Self approval is disabled!"
# Only one approval per run
if not run["approved"]:
run["approved"] = True
run["approver"] = approver
self.buffer(run, priority=Prio.SAVE_NOW)
return run, f"Run {str(run_id)} approved"
else:
return None, f"Run {str(run_id)} already approved!"
with self.active_run_lock(run_id):
if not run["approved"]:
run["approved"] = True
run["approver"] = approver
self.buffer(run, priority=Prio.SAVE_NOW)
return run, f"Run {str(run_id)} approved"
else:
return None, f"Run {str(run_id)} already approved!"

def purge_run(self, run, p=0.001, res=7.0, iters=1):
# Only purge finished runs
Expand Down

0 comments on commit c3e8210

Please sign in to comment.