- def loop (self):
- while self._running:
- if (self.state_to_set is not None):
- if self.state_to_set != self.state_last_set:
- stts = self.state_to_set # cache for parallelism
- error = do_request(stts) # TODO
- #TODO logging
- if not error:
- self.state_last_set = stts
- #TODO logging
- time.sleep(SPACE_API_LOOP_DELAY)
\ No newline at end of file
+ def _set_state (self, state = None):
+ '''Sets the state, if None: leave state unchanged and re-try if previous attempts failed'''
+ if state is not None:
+ self._state_to_set = state
+ # check if there's something we need to do
+ if self._state_last_set == self._state_to_set: return
+ # take action!
+ error = do_request(stts) # TODO
+ #TODO logging
+ if not error:
+ self.state_last_set = stts