Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Don't hit database most of the time.
Browse files Browse the repository at this point in the history
When we do hit the database, it is going to be hit from several threads
at the same time. Thanks to the WHERE condition only one of them wins.
  • Loading branch information
zwn authored and seanlinsley committed Mar 19, 2014
1 parent 70b2c02 commit 5641344
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions gittip/models/participant.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ def set_session_expires(self, expires):
:database: One UPDATE, one row
"""
if not self.session_expires + datetime.timedelta(hours=12) < expires:
return
with self.db.get_cursor() as c:
done = c.one("""
UPDATE participants SET session_expires=%(expires)s
Expand Down

0 comments on commit 5641344

Please sign in to comment.