Exemplo n.º 1
0
 def __schedule_action(self, *args, **kwargs):
     delay = args[0]
     
     if kwargs.has_key("start"):
         start = kwargs["start"]
     else:
         start = True
     
     
     timer = Timer(delay, self.__timer_action, args, kwargs)
     self._scheduled_timers.append(timer)
     
     if start:
         timer.start()
Exemplo n.º 2
0
def schedule(func, period, run_now=False):
    def wrapper():
        try:
            func()
        except Exception as e:  #pylint: disable=W0703
            LOG.error(e)
        finally:
            if not SHUTDOWN.is_set():
                schedule(func, period=period)
                sys.exit(0)

    t = Timer(0 if run_now else period, wrapper)

    t.start()