'Schedule and display events until time is up'

def run(self, end_time):

    for (_, proc) in sorted(self.procs.items()):
        first_event = next(proc)
        self.events.put(first_event)
    time = 0
    while (time < end_time):
        if self.events.empty():
            print '***    end    of    events    ***'
            break
        current_event = self.events.get()
        print ('taxi:', current_event.proc, (current_event.proc * '            '), current_event)
        time = current_event.time
        proc = self.procs[current_event.proc]
        try:
            next_event = proc.send(time)
        except StopIteration:
            del self.procs[current_event.proc]
        else:
            self.events.put(next_event)
    else:
        msg = '***    end    of    simulation    time:    {}    events    pending    ***'
        print msg.format(self.events.qsize())
