From def8c0dd76a178beb571815fdcf81eed64880727 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 16 May 2021 00:16:19 +0200 Subject: [PATCH] The joystick backend should properly jstest even when the jstest executable fails --- platypush/backend/joystick/jstest.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/platypush/backend/joystick/jstest.py b/platypush/backend/joystick/jstest.py index ff544505e..5a78e8985 100644 --- a/platypush/backend/joystick/jstest.py +++ b/platypush/backend/joystick/jstest.py @@ -185,7 +185,10 @@ class JoystickJstestBackend(Backend): return JoystickState(axes=axes, buttons=buttons) def _initialize(self): - while os.path.exists(self.device) and not self.should_stop() and not self._state: + while self._process.poll() is None and \ + os.path.exists(self.device) and \ + not self.should_stop() and \ + not self._state: line = b'' ch = None @@ -251,8 +254,11 @@ class JoystickJstestBackend(Backend): self.logger.info('Device opened') self._initialize() + if self._process.poll() is not None: + break + for state in self._read_states(): - if not os.path.exists(self.device): + if self._process.poll() is not None or not os.path.exists(self.device): self.logger.warning(f'Connection to {self.device} lost') self.bus.post(JoystickDisconnectedEvent(self.device)) break