Skip to content

Commit 256e90a

Browse files
committed
Change polling the existing lock from every 0.5s to every half of ttl
1 parent 1ad45b5 commit 256e90a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pytest_lab/locker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def check_lock(record):
135135
record = self.backend.read(key)
136136
if not record:
137137
return True
138-
time.sleep(0.5)
138+
time.sleep(record.ttl // 2)
139139
else:
140140
return True
141141

@@ -144,7 +144,7 @@ def check_lock(record):
144144
if not wait_on_locks:
145145
raise ResourceLocked(
146146
'{} is currently locked by {}'.format(key, record.value))
147-
while True:
147+
while wait_on_locks:
148148
if check_lock(record):
149149
break
150150

0 commit comments

Comments
 (0)