-
Notifications
You must be signed in to change notification settings - Fork 7
Task leases (fixes #18) #28
base: develop
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #28 +/- ##
===========================================
+ Coverage 60.55% 63.16% +2.61%
===========================================
Files 21 23 +2
Lines 1397 1496 +99
Branches 157 160 +3
===========================================
+ Hits 846 945 +99
Misses 511 511
Partials 40 40
Continue to review full report at Codecov.
|
has been acquired, `False` if an existing active lease is found. | ||
""" | ||
key = _key(task, args) | ||
if Session.objects.filter( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would get_or_create
be simpler here? It returns a tuple of (object, created)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_or_create
doesn't let me check the expire_date
in the query, but it does require me to pass it as a default for the creation step. While this makes the creation of a new object easier (it happens as part of get_or_create
), it makes handling an existing but expired object harder because I'd have to check and update expire_date
as appropriate. It's about the same amount of code as doing it this way, but the logic for checking if we properly got the lease is split up and less readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, yes.
other than the get_or_create suggestion 👍 |
No description provided.