def __init__(self, func, interval, max_run_time): StateController.__init__(self) self._func = func self._gap = interval self._max_run_time = max_run_time self._thread = threading.Thread(target=self._loop_thread) self._thread.daemon = True self._lock = threading.Lock() self._loop_active = True
def stop(self): with self._lock: self._loop_active = False self._thread.join(timeout=20) StateController.stop(self)
def start(self): StateController.start(self) self._thread.start()