Ejemplo n.º 1
0
 def __init__(self, **kwargs):
     threading.Thread.__init__(self)
     #self.timeout = kwargs.get('timeout', .001)
     self.callback = kwargs.get('callback')
     self.running = True
     self.needs_update = threading.Event()
     self.auto_update_timer = RepeatTimer(3.0, self.on_update_request)
Ejemplo n.º 2
0
class DMXTimeout(threading.Thread):
    def __init__(self, **kwargs):
        threading.Thread.__init__(self)
        #self.timeout = kwargs.get('timeout', .001)
        self.callback = kwargs.get('callback')
        self.running = True
        self.needs_update = threading.Event()
        self.auto_update_timer = RepeatTimer(3.0, self.on_update_request)
        #self.start_timer()
        
    def run(self):
        self.auto_update_timer.start()
        while self.running:
            self.needs_update.wait()
            self.callback()
            self.needs_update.clear()
        self.auto_update_timer.cancel()
            
    def on_update_request(self, *args, **kwargs):
        self.needs_update.set()