python类_Timer()的实例源码

danish.py 文件源码 项目:danish 作者: smutt 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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
main.py 文件源码 项目:plex-for-kodi-mod 作者: mrclemds 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def waitForThreads():
    util.DEBUG_LOG('Checking for any remaining threads')
    while len(threading.enumerate()) > 1:
        for t in threading.enumerate():
            if t != threading.currentThread():
                if t.isAlive():
                    util.DEBUG_LOG('Waiting on: {0}...'.format(t.name))
                    if isinstance(t, threading._Timer):
                        t.cancel()
                        t.join()
                    elif isinstance(t, threadutils.KillableThread):
                        t.kill(force_and_wait=True)
                    else:
                        t.join()


问题


面经


文章

微信
公众号

扫码关注公众号