From c1b87356ce5be50a0fac3307ed7ade751765c7aa Mon Sep 17 00:00:00 2001 From: richard-dds Date: Tue, 17 Sep 2019 11:06:23 -0400 Subject: [PATCH] Update session while claiming Not totally sure if this is necessary, but I feel like it makes more sense to err on the side of more data correctness, rather than hypothesizing about performance --- atst/models/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/atst/models/utils.py b/atst/models/utils.py index 6fb6a08b..fe0fe4f7 100644 --- a/atst/models/utils.py +++ b/atst/models/utils.py @@ -21,7 +21,7 @@ def claim_for_update(resource, minutes=30): or_(Model.claimed_until == None, Model.claimed_until < func.now()), ) ) - .update({"claimed_until": claim_until}, synchronize_session=False) + .update({"claimed_until": claim_until}, synchronize_session="fetch") ) if rows_updated < 1: raise ClaimFailedException(resource) @@ -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=False) + ).update({"claimed_until": sql.null()}, synchronize_session="fetch")