'Clear the queues for anything older than N minutes'

def _clear_queue(self):

    FIVE_MINUTES_AGO = ((5 * 60) * 1000)
    now = self.clock.time_msec()
    keys = self.pos_time.keys()
    time = keys.bisect_left((now - FIVE_MINUTES_AGO))
    if (not keys[:time]):
        return
    position_to_delete = max(keys[:time])
    for key in keys[:time]:
        del self.pos_time[key]
    self._clear_queue_before_pos(position_to_delete)
