def delayed_burst_run(self, target_cycles_per_sec):
old_cycles = self.cycles<EOL>start_time = time.time()<EOL>self.burst_run()<EOL>is_duration = time.time() - start_time<EOL>new_cycles = self.cycles - old_cycles<EOL>try:<EOL><INDENT>is_cycles_per_sec = new_cycles / is_duration<EOL><DEDENT>except ZeroDivisionError:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>should_burst_duration = is_cycles_per_sec / target_cycles_per_sec<EOL>target_duration = should_burst_duration * is_duration<EOL>delay = target_duration - is_duration<EOL>if delay > <NUM_LIT:0>:<EOL><INDENT>if delay > self.max_delay:<EOL><INDENT>self.delay = self.max_delay<EOL><DEDENT>else:<EOL><INDENT>self.delay = delay<EOL><DEDENT>time.sleep(self.delay)<EOL><DEDENT><DEDENT>self.call_sync_callbacks()<EOL>
Run CPU not faster than given speedlimit