self.handler = userHandler if userHandler is not None else self.defaultHandler
self.timer = Timer(self.timeout, self.handler)

def reset(self):
    self.timer.cancel()
self.timer = Timer(self.timeout, self.handler)

def stop(self):
    self.timer.cancel()

def defaultHandler(self):
    raise self
How to implement a watchdog timer in Python?