diff --git a/atst/models/utils.py b/atst/models/utils.py index fe0fe4f7..e7b69032 100644 --- a/atst/models/utils.py +++ b/atst/models/utils.py @@ -33,4 +33,4 @@ def claim_for_update(resource, minutes=30): finally: db.session.query(Model).filter(Model.id == resource.id).filter( Model.claimed_until != None - ).update({"claimed_until": sql.null()}, synchronize_session="fetch") + ).update({"claimed_until": None}, synchronize_session="fetch") diff --git a/tests/test_jobs.py b/tests/test_jobs.py index 13ebb89e..7973936e 100644 --- a/tests/test_jobs.py +++ b/tests/test_jobs.py @@ -288,4 +288,10 @@ def test_claim_for_update(session): t1.join() t2.join() + session.refresh(environment) + + # Only FirstThread acquired a claim and wrote to satisfied_claims assert satisfied_claims == ["FirstThread"] + + # The claim is released as soon as work is done + assert environment.claimed_until is None