'Run a tick - one iteration of the scheduler.
Executes one due task per call.
Returns:
float: preferred delay in seconds for next call.'

def tick(self, event_t=event_t, min=min, heappop=heapq.heappop, heappush=heapq.heappush):

    adjust = self.adjust
    max_interval = self.max_interval
    if ((self._heap is None) or (not self.schedules_equal(self.old_schedulers, self.schedule))):
        self.old_schedulers = copy.copy(self.schedule)
        self.populate_heap()
    H = self._heap
    if (not H):
        return max_interval
    event = H[0]
    entry = event[2]
    (is_due, next_time_to_run) = self.is_due(entry)
    if is_due:
        verify = heappop(H)
        if (verify is event):
            next_entry = self.reserve(entry)
            self.apply_entry(entry, producer=self.producer)
            heappush(H, event_t(self._when(next_entry, next_time_to_run), event[1], next_entry))
            return 0
        else:
            heappush(H, verify)
            return min(verify[0], max_interval)
    return min((adjust(next_time_to_run) or max_interval), max_interval)
