From 9bc12ae367692863574c686830c3e49a701ee2dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Leborne?= Date: Wed, 20 Nov 2024 15:21:26 +0100 Subject: [PATCH] Simplify code dealing with state reception --- pyluos/device.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pyluos/device.py b/pyluos/device.py index 1dc6c0c..9ad8206 100644 --- a/pyluos/device.py +++ b/pyluos/device.py @@ -223,17 +223,16 @@ def nodes(self): # Poll state from hardware. def _poll_once(self): - self._state = self._io.read() - if self._state != []: - self._state['timestamp'] = time.time() - return self._state - return [] + state = self._io.read() + if state: + state['timestamp'] = time.time() + return state def _poll_and_up(self): while self._running: if not self._pause: state = self._poll_once() - if self._state != []: + if state: self._update(state) self._push_once() else: @@ -269,7 +268,7 @@ def _update(self, new_state): self._freedomLink._kill(service.alias) service._kill() s += "\n* Service " + str(service.alias) + " have been excluded from the network due to no responses." - + s += "\n*************************************************************" print(s) break