Skip to content

Commit

Permalink
Actual fix for lock event wait timeout.
Browse files Browse the repository at this point in the history
Fixes #110 and #111
  • Loading branch information
coleifer committed Dec 30, 2019
1 parent 9aea769 commit d1199f7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion walrus/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def acquire(self, block=True):
the lock.
:returns: Returns ``True`` if the lock was acquired.
"""
event_wait = self.ttl // 1000 if self.ttl else 1

while True:
acquired = self.database.run_script(
'lock_acquire',
Expand All @@ -88,7 +90,7 @@ def acquire(self, block=True):
# Perform a blocking pop on the event key. When a lock
# is released, a value is pushed into the list, which
# signals listeners that the lock is available.
self.database.blpop(self.event, self.ttl)
self.database.blpop(self.event, event_wait)

def release(self):
"""
Expand Down

0 comments on commit d1199f7

Please sign in to comment.