Skip to content

Commit

Permalink
Change polling the existing lock from every 0.5s to every half of ttl
Browse files Browse the repository at this point in the history
  • Loading branch information
jfan666 committed Jun 13, 2018
1 parent 1ad45b5 commit 256e90a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pytest_lab/locker.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def check_lock(record):
record = self.backend.read(key)
if not record:
return True
time.sleep(0.5)
time.sleep(record.ttl // 2)
else:
return True

Expand All @@ -144,7 +144,7 @@ def check_lock(record):
if not wait_on_locks:
raise ResourceLocked(
'{} is currently locked by {}'.format(key, record.value))
while True:
while wait_on_locks:
if check_lock(record):
break

Expand Down

0 comments on commit 256e90a

Please sign in to comment.