def t_scheduled(self, interval, iterations, sleep_time=0):
        warmup_iterations = iterations

        self.last_t = 0.
        self.timer_count = 0
        def f(dt):
            t = time()
            self.timer_count += 1
            tc = self.timer_count
            if tc > warmup_iterations:
                self.assertAlmostEqual(dt, interval, places=2)
                self.assertAlmostEqual(t - self.last_t, interval, places=2)
            self.last_t = t

            if self.timer_count > iterations + warmup_iterations:
                pyglet.app.exit()
            if sleep_time:
                sleep(sleep_time)

        pyglet.clock.schedule_interval(f, interval)
        try:
            pyglet.app.run()
        finally:
            pyglet.clock.unschedule(f)
dataset/ETHPy150Open ardekantur/pyglet/tests/app/EVENT_LOOP.py/EVENT_LOOP.t_scheduled/original