class Ticker(threading.Thread):
    """A very simple thread that merely blocks for :attr:`interval` and sets a
  :class:`threading.Event` when the :attr:`interval` has elapsed. It then waits
  for the caller to unset this event before looping again.
  Example use::
    t = Ticker(1.0) 
    t.start() 
    try:
      while t.evt.wait(): 
        t.evt.clear() 
        print time.time(), "FIRING!"
    except:
      t.stop() 
      t.join() 
  """

def __init__(self, interval):
    super(Ticker, self).__init__()
self.interval = interval
self.evt = threading.Event()
self.evt.clear()
self.should_run = threading.Event()
self.should_run.set()

def stop(self):
    """Stop the this thread. You probably want to call :meth:`join` immediately
    afterwards
    """
self.should_run.clear()

def consume(self):
    was_set = self.evt.is_set()
if was_set:
    self.evt.clear()
return was_set

def run(self):
    """The internal main method of this thread. Block for :attr:`interval`
    seconds before setting :attr:`Ticker.evt`
    .. warning::
      Do not call this directly!  Instead call :meth:`start`.
    """
while self.should_run.is_set():
    time.sleep(self.interval)
self.evt.set()
python: Windows-эквивалент SIGALRM