Skip to content

Commit c6b98c6

Browse files
committed
Fix the sleep-wait in EmulatorLock.wait
Also added a note about adding a launch method
1 parent ca32f0e commit c6b98c6

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

sense_emu/lock.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,16 @@ def wait(self, timeout=None):
131131
elapsed, or ``False`` otherwise. If *timeout* is ``None`` (the default)
132132
wait indefinitely.
133133
"""
134+
# XXX Either add a "launch" param to this method, or add a launch
135+
# method to the class so that consumers can use the lock to launch
136+
# an appropriate emulation
134137
end = time()
135-
if timeout is None:
136-
wait = 0.1
137-
else:
138+
if timeout is not None:
138139
end += timeout
139-
wait = max(0, timeout / 10)
140140
while not self._is_held() or self._is_stale():
141141
if time() > end:
142142
return False
143-
sleep(wait)
143+
sleep(0.1)
144144
return True
145145

146146
@property
@@ -192,4 +192,3 @@ def _write_pid(self):
192192
self._filename, os.O_CREAT | os.O_EXCL | os.O_WRONLY, mode), 'w')
193193
lockfile.write('%d\n' % os.getpid())
194194
lockfile.close()
195-

0 commit comments

Comments
 (0)