import utils def run(ops, delay=0): def ret(): for init, run in ops: init() begin = get_tick_count() while get_tick_count()-begin < delay: do_a_flip() while True: for init, run in ops: if run(): return return ret