Jobs: _claim_job docstring states the invariant, not the old race

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Roland 2026-09-15 14:38:38 -06:00
parent 9f8da18cd0
commit 09111b9bc5
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680

View file

@ -200,10 +200,7 @@ def cancel_job(job_id: str) -> dict:
def _claim_job(job_id: str) -> Optional[dict]:
"""Move a Job from PENDING to RUNNING in one step under the lock; returns the running record,
or None when the Job is no longer pending (cancelled while queued, or already claimed).
Reading the status and writing RUNNING separately let a cancel land in between and be
overwritten, running a Job the user had cancelled."""
or None when the Job is no longer pending (cancelled while queued, or already claimed)."""
with _lock():
record = _jobs().get(job_id)
if not record or record['status'] != PENDING: