Skip to content

Commit

Permalink
Merge pull request #202 from fleborne/feat/improve-state-reception
Browse files Browse the repository at this point in the history
Simplify code dealing with state reception
  • Loading branch information
nicolas-rabault authored Dec 3, 2024
2 parents 724eef2 + 9bc12ae commit 9001272
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions pyluos/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,17 +227,16 @@ def last_update(self) -> float:

# 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:
Expand Down Expand Up @@ -273,7 +272,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
Expand Down

0 comments on commit 9001272

Please sign in to comment.