TODO: use more_itertools.peekable instead
        :return: The current result item.
        :rtype: dict. 
        :raises StopIteration: If there is no current item.
970998
def peek(self):
        
        if self._cur_item is None:
            self._cur_item = next(self._ex_context)

        return self._cur_item
463307
def peekiter(iterable):
    """"""
    it = iter(iterable)
    one = next(it)

    def gen():
        """Generator that returns first and proxy other items from source"""
        yield one
        while True:
            yield next(it)
    return (one, gen())
966072
def get_items(self):
        
        if self.retrieved:
            raise errors.IllegalState('List has already been retrieved.')
        self.retrieved = True
        return objects.ItemList(self._results, runtime=self._runtime)
421956
def itemat(iterable, index):
    

    result = None

    handleindex = True

    if isinstance(iterable, dict):
        handleindex = False

    else:
        try:
            result = iterable[index]
        except TypeError:
            handleindex = False

    if not handleindex:
        iterator = iter(iterable)

        if index < 0:  # ensure index is positive
            index += len(iterable)

        while index >= 0:
            try:
                value = next(iterator)

            except StopIteration:
                raise IndexError(
                    "{0} index {1} out of range".format(
                        iterable.__class__, index
                    )
                )

            else:
                if index == 0:
                    result = value
                    break
                index -= 1

    return result
1345686
async def get(self):
        
        self._parent._check_closing()
        async with self._parent._async_not_empty:
            self._parent._sync_mutex.acquire()
            locked = True
            try:
                do_wait = True
                while do_wait:
                    do_wait = self._parent._qsize() == 0

                    if do_wait:
                        locked = False
                        self._parent._sync_mutex.release()
                        await self._parent._async_not_empty.wait()
                        self._parent._sync_mutex.acquire()
                        locked = True

                item = self._parent._get()
                self._parent._async_not_full.notify()
                self._parent._notify_sync_not_full()
                return item
            finally:
                if locked:
                    self._parent._sync_mutex.release()
961968
def iterator(self):
        

        for item in self.query.results():
            obj = self.resource(**item)

            yield obj
786473
def get_nowait(self):
        
        new_get = Future()

        with self._lock:
            if not self._get.done():
                raise QueueEmpty
            get, self._get = self._get, new_get

        hole = get.result()
        if not hole.done():
            # Restore the unfinished hole.
            new_get.set_result(hole)
            raise QueueEmpty

        node = hole.result()
        value = node.value
        new_hole, node.next = node.next, None
        new_get.set_result(new_hole)
        return value
467167
def next(self):
        
        # need new iterable?
        if self.r == self.repeats:
            self.i = (self.i + 1) % self.lenght
            self.r = 0

        self.r += 1
        if self.stopping and self.i == 0 and self.r == 1:
            self.stopped = True
        if self.i == 0 and self.stopped:
            raise StopIteration
        else:
            iterator = self.iterators[self.i]
            return iterator.next()
1209943
def next(self):
        """"""
        # pylint: disable=protected-access
        with self._pcontext._queuelock:
            # Check that the pool still deals with this loop.
            # pylint: disable=protected-access
            pool_loop_reached = max(self._pcontext._thread_loop_ids)
            if pool_loop_reached > self._loop_id or self._queue.empty():
                raise StopIteration()
            else:
                return self._queue.get()
429127
def next(self):
        """"""
        if self._iter_n < self.n_blocks:
            result = self[self._iter_n]
            self._iter_n += 1
            return result
        else:
            raise StopIteration
1331999
def result(self):
        
        # Send None to all threads to cleanly stop them
        for _ in range(self.num_threads):
            self.tasks_queue.put(None)
        # Wait for completion of all the tasks in the queue
        self.tasks_queue.join()
        # Check if one of the thread raised an exception, if yes
        # raise it here in the function
        if not self.exceptions_queue.empty():
            raise self.exceptions_queue.get()
        return self.results_queue
352517
def _get_next_buffered_row(self):
        
        if self._iter_row == self._iter_nrows:
            raise StopIteration

        if self._row_buffer_index >= self._iter_row_buffer:
            self._buffer_iter_rows(self._iter_row)

        data = self._row_buffer[self._row_buffer_index]
        self._iter_row += 1
        self._row_buffer_index += 1
        return data
1224512
def collect_results(self) -> Optional[Tuple[int, Dict[str, float]]]:
        
        self.wait_to_finish()
        if self.decoder_metric_queue.empty():
            if self._results_pending:
                self._any_process_died = True
            self._results_pending = False
            return None
        decoded_checkpoint, decoder_metrics = self.decoder_metric_queue.get()
        assert self.decoder_metric_queue.empty()
        self._results_pending = False
        logger.info("Decoder-%d finished: %s", decoded_checkpoint, decoder_metrics)
        return decoded_checkpoint, decoder_metrics
112976
def windowed_iterable(self):
        
        # Seek to offset
        effective_offset = max(0,self.item_view.iterable_index)
        for i,item in enumerate(self.iterable):
            if i<effective_offset:
                continue
            elif i>=(effective_offset+self.item_view.iterable_fetch_size):
                return
            yield item
818616
def get_next_item(iterable):
    """"""
    try: x = iterable.next()
    except StopIteration: x = None
    except AttributeError: x = None
    return x
456253
def Next(self):
        
        try:
            self.key, self.value = next(self.current)
        except StopIteration:

            if self.current != self.second:
                self.current = self.second
                return self.Next()

            return False

        return True
777674
def peek(self, default=_marker):
        
        if not hasattr(self, '_peek'):
            try:
                self._peek = next(self._it)
            except StopIteration:
                if default is _marker:
                    raise
                return default
        return self._peek