def dispatcher(): done = exiting while not done: sleep(0.001) with lock: done = exiting current = time() for k, v in down_keys.items(): if current > v: print 'key is: ', k send_key(k, True, True) down_keys[k] = time() + repeat_interval print 'dispatching'
def send_down(key, delay): with lock: send_key(key, True) down_keys[key] = delay
def send_up(key): with lock: send_key(key, False) del down_keys[key]