Skip to content

Commit

Permalink
Simplify code dealing with state reception
Browse files Browse the repository at this point in the history
  • Loading branch information
fleborne committed Nov 20, 2024
1 parent 7b1ca02 commit 9bc12ae
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 @@ -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:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9bc12ae

Please sign in to comment.