def __iter__(self): if not self.intervals: return while True: e = heappop(self.intervals) next_run = e.point[0] heappush(self.intervals, e.shift()) yield next_run, e.action