python类_last_iteration()的实例源码

asyncsupport.py 文件源码 项目:Sci-Finder 作者: snverse 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def make_async_loop_context(iterable, recurse=None, depth0=0):
    # Length is more complicated and less efficient in async mode.  The
    # reason for this is that we cannot know if length will be used
    # upfront but because length is a property we cannot lazily execute it
    # later.  This means that we need to buffer it up and measure :(
    #
    # We however only do this for actual iterators, not for async
    # iterators as blocking here does not seem like the best idea in the
    # world.
    try:
        length = len(iterable)
    except (TypeError, AttributeError):
        if not hasattr(iterable, '__aiter__'):
            iterable = tuple(iterable)
            length = len(iterable)
        else:
            length = None
    async_iterator = auto_aiter(iterable)
    try:
        after = await async_iterator.__anext__()
    except StopAsyncIteration:
        after = _last_iteration
    return AsyncLoopContext(async_iterator, after, length, recurse, depth0)
asyncsupport.py 文件源码 项目:Sci-Finder 作者: snverse 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def make_async_loop_context(iterable, recurse=None, depth0=0):
    # Length is more complicated and less efficient in async mode.  The
    # reason for this is that we cannot know if length will be used
    # upfront but because length is a property we cannot lazily execute it
    # later.  This means that we need to buffer it up and measure :(
    #
    # We however only do this for actual iterators, not for async
    # iterators as blocking here does not seem like the best idea in the
    # world.
    try:
        length = len(iterable)
    except (TypeError, AttributeError):
        if not hasattr(iterable, '__aiter__'):
            iterable = tuple(iterable)
            length = len(iterable)
        else:
            length = None
    async_iterator = auto_aiter(iterable)
    try:
        after = await async_iterator.__anext__()
    except StopAsyncIteration:
        after = _last_iteration
    return AsyncLoopContext(async_iterator, after, length, recurse, depth0)
asyncsupport.py 文件源码 项目:RPoint 作者: george17-meet 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def make_async_loop_context(iterable, recurse=None, depth0=0):
    # Length is more complicated and less efficient in async mode.  The
    # reason for this is that we cannot know if length will be used
    # upfront but because length is a property we cannot lazily execute it
    # later.  This means that we need to buffer it up and measure :(
    #
    # We however only do this for actual iterators, not for async
    # iterators as blocking here does not seem like the best idea in the
    # world.
    try:
        length = len(iterable)
    except (TypeError, AttributeError):
        if not hasattr(iterable, '__aiter__'):
            iterable = tuple(iterable)
            length = len(iterable)
        else:
            length = None
    async_iterator = auto_aiter(iterable)
    try:
        after = await async_iterator.__anext__()
    except StopAsyncIteration:
        after = _last_iteration
    return AsyncLoopContext(async_iterator, after, length, recurse, depth0)
asyncsupport.py 文件源码 项目:RealtimePythonChat 作者: quangtqag 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def make_async_loop_context(iterable, recurse=None, depth0=0):
    # Length is more complicated and less efficient in async mode.  The
    # reason for this is that we cannot know if length will be used
    # upfront but because length is a property we cannot lazily execute it
    # later.  This means that we need to buffer it up and measure :(
    #
    # We however only do this for actual iterators, not for async
    # iterators as blocking here does not seem like the best idea in the
    # world.
    try:
        length = len(iterable)
    except (TypeError, AttributeError):
        if not hasattr(iterable, '__aiter__'):
            iterable = tuple(iterable)
            length = len(iterable)
        else:
            length = None
    async_iterator = auto_aiter(iterable)
    try:
        after = await async_iterator.__anext__()
    except StopAsyncIteration:
        after = _last_iteration
    return AsyncLoopContext(async_iterator, after, length, recurse, depth0)
asyncsupport.py 文件源码 项目:Indushell 作者: SecarmaLabs 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def make_async_loop_context(iterable, recurse=None, depth0=0):
    # Length is more complicated and less efficient in async mode.  The
    # reason for this is that we cannot know if length will be used
    # upfront but because length is a property we cannot lazily execute it
    # later.  This means that we need to buffer it up and measure :(
    #
    # We however only do this for actual iterators, not for async
    # iterators as blocking here does not seem like the best idea in the
    # world.
    try:
        length = len(iterable)
    except (TypeError, AttributeError):
        if not hasattr(iterable, '__aiter__'):
            iterable = tuple(iterable)
            length = len(iterable)
        else:
            length = None
    async_iterator = auto_aiter(iterable)
    try:
        after = await async_iterator.__anext__()
    except StopAsyncIteration:
        after = _last_iteration
    return AsyncLoopContext(async_iterator, after, length, recurse, depth0)
asyncsupport.py 文件源码 项目:Liljimbo-Chatbot 作者: chrisjim316 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def make_async_loop_context(iterable, recurse=None, depth0=0):
    # Length is more complicated and less efficient in async mode.  The
    # reason for this is that we cannot know if length will be used
    # upfront but because length is a property we cannot lazily execute it
    # later.  This means that we need to buffer it up and measure :(
    #
    # We however only do this for actual iterators, not for async
    # iterators as blocking here does not seem like the best idea in the
    # world.
    try:
        length = len(iterable)
    except (TypeError, AttributeError):
        if not hasattr(iterable, '__aiter__'):
            iterable = tuple(iterable)
            length = len(iterable)
        else:
            length = None
    async_iterator = auto_aiter(iterable)
    try:
        after = await async_iterator.__anext__()
    except StopAsyncIteration:
        after = _last_iteration
    return AsyncLoopContext(async_iterator, after, length, recurse, depth0)
asyncsupport.py 文件源码 项目:flask_system 作者: prashasy 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def make_async_loop_context(iterable, recurse=None, depth0=0):
    # Length is more complicated and less efficient in async mode.  The
    # reason for this is that we cannot know if length will be used
    # upfront but because length is a property we cannot lazily execute it
    # later.  This means that we need to buffer it up and measure :(
    #
    # We however only do this for actual iterators, not for async
    # iterators as blocking here does not seem like the best idea in the
    # world.
    try:
        length = len(iterable)
    except (TypeError, AttributeError):
        if not hasattr(iterable, '__aiter__'):
            iterable = tuple(iterable)
            length = len(iterable)
        else:
            length = None
    async_iterator = auto_aiter(iterable)
    try:
        after = await async_iterator.__anext__()
    except StopAsyncIteration:
        after = _last_iteration
    return AsyncLoopContext(async_iterator, after, length, recurse, depth0)
asyncsupport.py 文件源码 项目:ShelbySearch 作者: Agentscreech 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def make_async_loop_context(iterable, recurse=None, depth0=0):
    # Length is more complicated and less efficient in async mode.  The
    # reason for this is that we cannot know if length will be used
    # upfront but because length is a property we cannot lazily execute it
    # later.  This means that we need to buffer it up and measure :(
    #
    # We however only do this for actual iterators, not for async
    # iterators as blocking here does not seem like the best idea in the
    # world.
    try:
        length = len(iterable)
    except (TypeError, AttributeError):
        if not hasattr(iterable, '__aiter__'):
            iterable = tuple(iterable)
            length = len(iterable)
        else:
            length = None
    async_iterator = auto_aiter(iterable)
    try:
        after = await async_iterator.__anext__()
    except StopAsyncIteration:
        after = _last_iteration
    return AsyncLoopContext(async_iterator, after, length, recurse, depth0)
asyncsupport.py 文件源码 项目:FileStoreGAE 作者: liantian-cn 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def make_async_loop_context(iterable, recurse=None, depth0=0):
    # Length is more complicated and less efficient in async mode.  The
    # reason for this is that we cannot know if length will be used
    # upfront but because length is a property we cannot lazily execute it
    # later.  This means that we need to buffer it up and measure :(
    #
    # We however only do this for actual iterators, not for async
    # iterators as blocking here does not seem like the best idea in the
    # world.
    try:
        length = len(iterable)
    except (TypeError, AttributeError):
        if not hasattr(iterable, '__aiter__'):
            iterable = tuple(iterable)
            length = len(iterable)
        else:
            length = None
    async_iterator = auto_aiter(iterable)
    try:
        after = await async_iterator.__anext__()
    except StopAsyncIteration:
        after = _last_iteration
    return AsyncLoopContext(async_iterator, after, length, recurse, depth0)
asyncsupport.py 文件源码 项目:python-group-proj 作者: Sharcee 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def make_async_loop_context(iterable, recurse=None, depth0=0):
    # Length is more complicated and less efficient in async mode.  The
    # reason for this is that we cannot know if length will be used
    # upfront but because length is a property we cannot lazily execute it
    # later.  This means that we need to buffer it up and measure :(
    #
    # We however only do this for actual iterators, not for async
    # iterators as blocking here does not seem like the best idea in the
    # world.
    try:
        length = len(iterable)
    except (TypeError, AttributeError):
        if not hasattr(iterable, '__aiter__'):
            iterable = tuple(iterable)
            length = len(iterable)
        else:
            length = None
    async_iterator = auto_aiter(iterable)
    try:
        after = await async_iterator.__anext__()
    except StopAsyncIteration:
        after = _last_iteration
    return AsyncLoopContext(async_iterator, after, length, recurse, depth0)
asyncsupport.py 文件源码 项目:islam-buddy 作者: hamir 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def make_async_loop_context(iterable, recurse=None, depth0=0):
    # Length is more complicated and less efficient in async mode.  The
    # reason for this is that we cannot know if length will be used
    # upfront but because length is a property we cannot lazily execute it
    # later.  This means that we need to buffer it up and measure :(
    #
    # We however only do this for actual iterators, not for async
    # iterators as blocking here does not seem like the best idea in the
    # world.
    try:
        length = len(iterable)
    except (TypeError, AttributeError):
        if not hasattr(iterable, '__aiter__'):
            iterable = tuple(iterable)
            length = len(iterable)
        else:
            length = None
    async_iterator = auto_aiter(iterable)
    try:
        after = await async_iterator.__anext__()
    except StopAsyncIteration:
        after = _last_iteration
    return AsyncLoopContext(async_iterator, after, length, recurse, depth0)
asyncsupport.py 文件源码 项目:PornGuys 作者: followloda 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def make_async_loop_context(iterable, recurse=None, depth0=0):
    # Length is more complicated and less efficient in async mode.  The
    # reason for this is that we cannot know if length will be used
    # upfront but because length is a property we cannot lazily execute it
    # later.  This means that we need to buffer it up and measure :(
    #
    # We however only do this for actual iterators, not for async
    # iterators as blocking here does not seem like the best idea in the
    # world.
    try:
        length = len(iterable)
    except (TypeError, AttributeError):
        if not hasattr(iterable, '__aiter__'):
            iterable = tuple(iterable)
            length = len(iterable)
        else:
            length = None
    async_iterator = auto_aiter(iterable)
    try:
        after = await async_iterator.__anext__()
    except StopAsyncIteration:
        after = _last_iteration
    return AsyncLoopContext(async_iterator, after, length, recurse, depth0)
asyncsupport.py 文件源码 项目:jieba-GAE 作者: liantian-cn 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def make_async_loop_context(iterable, recurse=None, depth0=0):
    # Length is more complicated and less efficient in async mode.  The
    # reason for this is that we cannot know if length will be used
    # upfront but because length is a property we cannot lazily execute it
    # later.  This means that we need to buffer it up and measure :(
    #
    # We however only do this for actual iterators, not for async
    # iterators as blocking here does not seem like the best idea in the
    # world.
    try:
        length = len(iterable)
    except (TypeError, AttributeError):
        if not hasattr(iterable, '__aiter__'):
            iterable = tuple(iterable)
            length = len(iterable)
        else:
            length = None
    async_iterator = auto_aiter(iterable)
    try:
        after = await async_iterator.__anext__()
    except StopAsyncIteration:
        after = _last_iteration
    return AsyncLoopContext(async_iterator, after, length, recurse, depth0)
asyncsupport.py 文件源码 项目:webapp 作者: superchilli 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def make_async_loop_context(iterable, recurse=None, depth0=0):
    # Length is more complicated and less efficient in async mode.  The
    # reason for this is that we cannot know if length will be used
    # upfront but because length is a property we cannot lazily execute it
    # later.  This means that we need to buffer it up and measure :(
    #
    # We however only do this for actual iterators, not for async
    # iterators as blocking here does not seem like the best idea in the
    # world.
    try:
        length = len(iterable)
    except (TypeError, AttributeError):
        if not hasattr(iterable, '__aiter__'):
            iterable = tuple(iterable)
            length = len(iterable)
        else:
            length = None
    async_iterator = auto_aiter(iterable)
    try:
        after = await async_iterator.__anext__()
    except StopAsyncIteration:
        after = _last_iteration
    return AsyncLoopContext(async_iterator, after, length, recurse, depth0)
asyncsupport.py 文件源码 项目:pipenv 作者: pypa 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def make_async_loop_context(iterable, recurse=None, depth0=0):
    # Length is more complicated and less efficient in async mode.  The
    # reason for this is that we cannot know if length will be used
    # upfront but because length is a property we cannot lazily execute it
    # later.  This means that we need to buffer it up and measure :(
    #
    # We however only do this for actual iterators, not for async
    # iterators as blocking here does not seem like the best idea in the
    # world.
    try:
        length = len(iterable)
    except (TypeError, AttributeError):
        if not hasattr(iterable, '__aiter__'):
            iterable = tuple(iterable)
            length = len(iterable)
        else:
            length = None
    async_iterator = auto_aiter(iterable)
    try:
        after = await async_iterator.__anext__()
    except StopAsyncIteration:
        after = _last_iteration
    return AsyncLoopContext(async_iterator, after, length, recurse, depth0)
asyncsupport.py 文件源码 项目:QualquerMerdaAPI 作者: tiagovizoto 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def make_async_loop_context(iterable, recurse=None, depth0=0):
    # Length is more complicated and less efficient in async mode.  The
    # reason for this is that we cannot know if length will be used
    # upfront but because length is a property we cannot lazily execute it
    # later.  This means that we need to buffer it up and measure :(
    #
    # We however only do this for actual iterators, not for async
    # iterators as blocking here does not seem like the best idea in the
    # world.
    try:
        length = len(iterable)
    except (TypeError, AttributeError):
        if not hasattr(iterable, '__aiter__'):
            iterable = tuple(iterable)
            length = len(iterable)
        else:
            length = None
    async_iterator = auto_aiter(iterable)
    try:
        after = await async_iterator.__anext__()
    except StopAsyncIteration:
        after = _last_iteration
    return AsyncLoopContext(async_iterator, after, length, recurse, depth0)
asyncsupport.py 文件源码 项目:gardenbot 作者: GoestaO 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def make_async_loop_context(iterable, recurse=None, depth0=0):
    # Length is more complicated and less efficient in async mode.  The
    # reason for this is that we cannot know if length will be used
    # upfront but because length is a property we cannot lazily execute it
    # later.  This means that we need to buffer it up and measure :(
    #
    # We however only do this for actual iterators, not for async
    # iterators as blocking here does not seem like the best idea in the
    # world.
    try:
        length = len(iterable)
    except (TypeError, AttributeError):
        if not hasattr(iterable, '__aiter__'):
            iterable = tuple(iterable)
            length = len(iterable)
        else:
            length = None
    async_iterator = auto_aiter(iterable)
    try:
        after = await async_iterator.__anext__()
    except StopAsyncIteration:
        after = _last_iteration
    return AsyncLoopContext(async_iterator, after, length, recurse, depth0)
asyncsupport.py 文件源码 项目:flask-zhenai-mongo-echarts 作者: Fretice 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def make_async_loop_context(iterable, recurse=None, depth0=0):
    # Length is more complicated and less efficient in async mode.  The
    # reason for this is that we cannot know if length will be used
    # upfront but because length is a property we cannot lazily execute it
    # later.  This means that we need to buffer it up and measure :(
    #
    # We however only do this for actual iterators, not for async
    # iterators as blocking here does not seem like the best idea in the
    # world.
    try:
        length = len(iterable)
    except (TypeError, AttributeError):
        if not hasattr(iterable, '__aiter__'):
            iterable = tuple(iterable)
            length = len(iterable)
        else:
            length = None
    async_iterator = auto_aiter(iterable)
    try:
        after = await async_iterator.__anext__()
    except StopAsyncIteration:
        after = _last_iteration
    return AsyncLoopContext(async_iterator, after, length, recurse, depth0)
asyncsupport.py 文件源码 项目:hate-to-hugs 作者: sdoran35 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def make_async_loop_context(iterable, recurse=None, depth0=0):
    # Length is more complicated and less efficient in async mode.  The
    # reason for this is that we cannot know if length will be used
    # upfront but because length is a property we cannot lazily execute it
    # later.  This means that we need to buffer it up and measure :(
    #
    # We however only do this for actual iterators, not for async
    # iterators as blocking here does not seem like the best idea in the
    # world.
    try:
        length = len(iterable)
    except (TypeError, AttributeError):
        if not hasattr(iterable, '__aiter__'):
            iterable = tuple(iterable)
            length = len(iterable)
        else:
            length = None
    async_iterator = auto_aiter(iterable)
    try:
        after = await async_iterator.__anext__()
    except StopAsyncIteration:
        after = _last_iteration
    return AsyncLoopContext(async_iterator, after, length, recurse, depth0)
asyncsupport.py 文件源码 项目:ieee-cs-txst 作者: codestar12 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def make_async_loop_context(iterable, recurse=None, depth0=0):
    # Length is more complicated and less efficient in async mode.  The
    # reason for this is that we cannot know if length will be used
    # upfront but because length is a property we cannot lazily execute it
    # later.  This means that we need to buffer it up and measure :(
    #
    # We however only do this for actual iterators, not for async
    # iterators as blocking here does not seem like the best idea in the
    # world.
    try:
        length = len(iterable)
    except (TypeError, AttributeError):
        if not hasattr(iterable, '__aiter__'):
            iterable = tuple(iterable)
            length = len(iterable)
        else:
            length = None
    async_iterator = auto_aiter(iterable)
    try:
        after = await async_iterator.__anext__()
    except StopAsyncIteration:
        after = _last_iteration
    return AsyncLoopContext(async_iterator, after, length, recurse, depth0)
asyncsupport.py 文件源码 项目:deliver 作者: orchestor 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def make_async_loop_context(iterable, recurse=None, depth0=0):
    # Length is more complicated and less efficient in async mode.  The
    # reason for this is that we cannot know if length will be used
    # upfront but because length is a property we cannot lazily execute it
    # later.  This means that we need to buffer it up and measure :(
    #
    # We however only do this for actual iterators, not for async
    # iterators as blocking here does not seem like the best idea in the
    # world.
    try:
        length = len(iterable)
    except (TypeError, AttributeError):
        if not hasattr(iterable, '__aiter__'):
            iterable = tuple(iterable)
            length = len(iterable)
        else:
            length = None
    async_iterator = auto_aiter(iterable)
    try:
        after = await async_iterator.__anext__()
    except StopAsyncIteration:
        after = _last_iteration
    return AsyncLoopContext(async_iterator, after, length, recurse, depth0)
asyncsupport.py 文件源码 项目:sam-s-club-auctions 作者: sameer2800 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def make_async_loop_context(iterable, recurse=None, depth0=0):
    # Length is more complicated and less efficient in async mode.  The
    # reason for this is that we cannot know if length will be used
    # upfront but because length is a property we cannot lazily execute it
    # later.  This means that we need to buffer it up and measure :(
    #
    # We however only do this for actual iterators, not for async
    # iterators as blocking here does not seem like the best idea in the
    # world.
    try:
        length = len(iterable)
    except (TypeError, AttributeError):
        if not hasattr(iterable, '__aiter__'):
            iterable = tuple(iterable)
            length = len(iterable)
        else:
            length = None
    async_iterator = auto_aiter(iterable)
    try:
        after = await async_iterator.__anext__()
    except StopAsyncIteration:
        after = _last_iteration
    return AsyncLoopContext(async_iterator, after, length, recurse, depth0)
asyncsupport.py 文件源码 项目:WhatTheHack 作者: Sylphias 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def make_async_loop_context(iterable, recurse=None, depth0=0):
    # Length is more complicated and less efficient in async mode.  The
    # reason for this is that we cannot know if length will be used
    # upfront but because length is a property we cannot lazily execute it
    # later.  This means that we need to buffer it up and measure :(
    #
    # We however only do this for actual iterators, not for async
    # iterators as blocking here does not seem like the best idea in the
    # world.
    try:
        length = len(iterable)
    except (TypeError, AttributeError):
        if not hasattr(iterable, '__aiter__'):
            iterable = tuple(iterable)
            length = len(iterable)
        else:
            length = None
    async_iterator = auto_aiter(iterable)
    try:
        after = await async_iterator.__anext__()
    except StopAsyncIteration:
        after = _last_iteration
    return AsyncLoopContext(async_iterator, after, length, recurse, depth0)
asyncsupport.py 文件源码 项目:WhatTheHack 作者: Sylphias 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def make_async_loop_context(iterable, recurse=None, depth0=0):
    # Length is more complicated and less efficient in async mode.  The
    # reason for this is that we cannot know if length will be used
    # upfront but because length is a property we cannot lazily execute it
    # later.  This means that we need to buffer it up and measure :(
    #
    # We however only do this for actual iterators, not for async
    # iterators as blocking here does not seem like the best idea in the
    # world.
    try:
        length = len(iterable)
    except (TypeError, AttributeError):
        if not hasattr(iterable, '__aiter__'):
            iterable = tuple(iterable)
            length = len(iterable)
        else:
            length = None
    async_iterator = auto_aiter(iterable)
    try:
        after = await async_iterator.__anext__()
    except StopAsyncIteration:
        after = _last_iteration
    return AsyncLoopContext(async_iterator, after, length, recurse, depth0)
asyncsupport.py 文件源码 项目:blog_flask 作者: momantai 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def make_async_loop_context(iterable, recurse=None, depth0=0):
    # Length is more complicated and less efficient in async mode.  The
    # reason for this is that we cannot know if length will be used
    # upfront but because length is a property we cannot lazily execute it
    # later.  This means that we need to buffer it up and measure :(
    #
    # We however only do this for actual iterators, not for async
    # iterators as blocking here does not seem like the best idea in the
    # world.
    try:
        length = len(iterable)
    except (TypeError, AttributeError):
        if not hasattr(iterable, '__aiter__'):
            iterable = tuple(iterable)
            length = len(iterable)
        else:
            length = None
    async_iterator = auto_aiter(iterable)
    try:
        after = await async_iterator.__anext__()
    except StopAsyncIteration:
        after = _last_iteration
    return AsyncLoopContext(async_iterator, after, length, recurse, depth0)
asyncsupport.py 文件源码 项目:flask 作者: bobohope 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def make_async_loop_context(iterable, recurse=None, depth0=0):
    # Length is more complicated and less efficient in async mode.  The
    # reason for this is that we cannot know if length will be used
    # upfront but because length is a property we cannot lazily execute it
    # later.  This means that we need to buffer it up and measure :(
    #
    # We however only do this for actual iterators, not for async
    # iterators as blocking here does not seem like the best idea in the
    # world.
    try:
        length = len(iterable)
    except (TypeError, AttributeError):
        if not hasattr(iterable, '__aiter__'):
            iterable = tuple(iterable)
            length = len(iterable)
        else:
            length = None
    async_iterator = auto_aiter(iterable)
    try:
        after = await async_iterator.__anext__()
    except StopAsyncIteration:
        after = _last_iteration
    return AsyncLoopContext(async_iterator, after, length, recurse, depth0)
asyncsupport.py 文件源码 项目:Chorus 作者: DonaldBough 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def make_async_loop_context(iterable, recurse=None, depth0=0):
    # Length is more complicated and less efficient in async mode.  The
    # reason for this is that we cannot know if length will be used
    # upfront but because length is a property we cannot lazily execute it
    # later.  This means that we need to buffer it up and measure :(
    #
    # We however only do this for actual iterators, not for async
    # iterators as blocking here does not seem like the best idea in the
    # world.
    try:
        length = len(iterable)
    except (TypeError, AttributeError):
        if not hasattr(iterable, '__aiter__'):
            iterable = tuple(iterable)
            length = len(iterable)
        else:
            length = None
    async_iterator = auto_aiter(iterable)
    try:
        after = await async_iterator.__anext__()
    except StopAsyncIteration:
        after = _last_iteration
    return AsyncLoopContext(async_iterator, after, length, recurse, depth0)
asyncsupport.py 文件源码 项目:Sci-Finder 作者: snverse 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __anext__(self):
        ctx = self.context
        ctx.index0 += 1
        if ctx._after is _last_iteration:
            raise StopAsyncIteration()
        next_elem = ctx._after
        try:
            ctx._after = await ctx._async_iterator.__anext__()
        except StopAsyncIteration:
            ctx._after = _last_iteration
        return next_elem, ctx
asyncsupport.py 文件源码 项目:Sci-Finder 作者: snverse 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __anext__(self):
        ctx = self.context
        ctx.index0 += 1
        if ctx._after is _last_iteration:
            raise StopAsyncIteration()
        next_elem = ctx._after
        try:
            ctx._after = await ctx._async_iterator.__anext__()
        except StopAsyncIteration:
            ctx._after = _last_iteration
        return next_elem, ctx
asyncsupport.py 文件源码 项目:RPoint 作者: george17-meet 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def __anext__(self):
        ctx = self.context
        ctx.index0 += 1
        if ctx._after is _last_iteration:
            raise StopAsyncIteration()
        next_elem = ctx._after
        try:
            ctx._after = await ctx._async_iterator.__anext__()
        except StopAsyncIteration:
            ctx._after = _last_iteration
        return next_elem, ctx


问题


面经


文章

微信
公众号

扫码关注公众号