From 23261da3af8c7a64f1655eee8afc7db5b19ca86e Mon Sep 17 00:00:00 2001 From: richard-dds Date: Tue, 17 Sep 2019 11:15:25 -0400 Subject: [PATCH] Use None isntead of sql.null --- atst/models/utils.py | 2 +- tests/test_jobs.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) 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