'Make iteration over epochs easy.
Parameters
return_event_id : bool
If True, return both an epoch and and event_id.
Returns
epoch : instance of Epochs
The epoch.
event_id : int
The event id. Only returned if ``return_event_id`` is ``True``.'

def next(self, return_event_id=False):

    first = True
    while True:
        current_time = time.time()
        if (current_time > (self._last_time + self.isi_max)):
            logger.info(('Time    of    %s    seconds    exceeded.' % self.isi_max))
            return
        if (len(self._epoch_queue) > self._current):
            epoch = self._epoch_queue[self._current]
            event_id = self._events[self._current][(-1)]
            self._current += 1
            self._last_time = current_time
            return ((epoch, event_id) if return_event_id else epoch)
        if self._started:
            if first:
                logger.info(('Waiting    for    epoch    %d' % (self._current + 1)))
                first = False
            time.sleep(self._sleep_time)
        else:
            raise RuntimeError('Not    enough    epochs    in    queue    and    currently    not    receiving    epochs,    cannot    get    epochs!')
