forked from platypush/platypush
Wait until the joystick device is readable after it appears to prevent race conditions where jstest fails with temporary "permission denied" errors
This commit is contained in:
parent
def8c0dd76
commit
d7d5bcdd0c
1 changed files with 10 additions and 4 deletions
|
@ -100,11 +100,17 @@ class JoystickJstestBackend(Backend):
|
||||||
def _wait_ready(self):
|
def _wait_ready(self):
|
||||||
self.logger.info(f'Waiting for joystick device on {self.device}')
|
self.logger.info(f'Waiting for joystick device on {self.device}')
|
||||||
|
|
||||||
while not self.should_stop() and not os.path.exists(self.device):
|
while not self.should_stop():
|
||||||
|
if not os.path.exists(self.device):
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
if self.should_stop():
|
try:
|
||||||
return
|
with open(self.device, 'rb'):
|
||||||
|
break
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.debug(e)
|
||||||
|
time.sleep(0.1)
|
||||||
|
continue
|
||||||
|
|
||||||
self.bus.post(JoystickConnectedEvent(device=self.device))
|
self.bus.post(JoystickConnectedEvent(device=self.device))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue