Python threading._Timer() Examples

The following are code examples for showing how to use threading._Timer(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: 19626_Pushover   Author: ottonet   File: LogikGen.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self,interval,function):
        self.starttime = time.strftime("%H:%M:%S",time.localtime())
        self.calctime = time.time() + interval
        threading._Timer.__init__(self,interval, function) 
Example 2
Project: generic_bot   Author: Soinull   File: generic_bot.py    MIT License 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        threading._Timer.__init__(self, *args, **kwargs)
        self.setDaemon(True) 
Example 3
Project: danish   Author: smutt   File: danish.py    GNU General Public License v3.0 5 votes vote down vote up
def handleKilling(signal, frame):
  dbgLog(LOG_INFO, "SIG " + str(signal) + " caught, exiting")
  if LOG_OUTPUT == 'file':
    LOG_HANDLE.close()

  # Kill all timer threads
  for thr in threading.enumerate():
    if isinstance(thr, threading._Timer):
      try:
        thr.cancel()
      except:
        pass

  # Clean up iptables
  ipt('-D FORWARD -j ' + IPT_CHAIN)
  subChains = re.findall(re.compile(IPT_CHAIN + '_[a-z,0-9]{20}'), ipt('-L ' + IPT_CHAIN))
  ipt('-F ' + IPT_CHAIN)

  for chain in subChains:
    ipt('-F ' + chain)
    ipt('-X ' + chain)
  ipt('-X ' + IPT_CHAIN)

  if IP6_SUPPORT:
    ipt6('-D FORWARD -j ' + IPT_CHAIN)
    ipt6('-F ' + IPT_CHAIN)

    for chain in subChains:
      ipt6('-F ' + chain)
      ipt6('-X ' + chain)
    ipt6('-X ' + IPT_CHAIN)

  sys.exit(0)


# Logs message to LOG_FNAME or tty