How to use the aioitertools.builtins function in aioitertools

To help you get started, we’ve selected a few aioitertools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jreese / aioitertools / aioitertools / builtins.py View on Github external
"""
    Return the next item of any mixed iterator.

    Calls builtins.next() on standard iterators, and awaits itr.__anext__()
    on async iterators.

    Example:

        value = await next(it)

    """
    if isinstance(itr, AsyncIterator):
        return await itr.__anext__()

    try:
        return builtins.next(itr)
    except StopIteration:
        raise StopAsyncIteration