def change_period(self, new_period): self._renew_period = new_period if self._renew_handle: Planner.kill_task(self._renew_handle) self._renew_handle = None if self._renew_period > 0: self._renew_handle = Planner.repeat(self._renew_period, self._update_value)
def _add_listener(self, listener): if not self._listeners and self._renew_period > 0: self._renew_handle = Planner.repeat(self._renew_period, self._update_value) self._listeners.append(listener) self._handle_count += 1 return listener[0]