class ThreadWrapper(): def __init__(self): self.stopEvent = threading.Event() self.wrapper = Wrapper() self.sc = SensorControl() self.thrd = threading.Thread(target=self.writer) def reader(self): return self.wrapper.ss def writer(self): while not self.stopEvent.is_set(): self.wrapper.ss = self.sc.getDistances() #print self.wrapper.sc def start(self): self.thrd.start() def stop(self): self.stopEvent.set() self.thrd.join()
def __init__(self): self.stopEvent = threading.Event() self.wrapper = Wrapper() self.sc = SensorControl() self.thrd = threading.Thread(target=self.writer)