asynctest.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:aioprometheus 作者: claws 项目源码 文件源码
def isawaitable(obj):
    ''' Return True if the object is an awaitable or is a function that
    returns an awaitable.

    This function is used internally by aiotesting.
    '''
    if PY35:
        result = inspect.iscoroutinefunction(obj) or inspect.isawaitable(obj)

    elif PY34:
        result = (isinstance(obj, asyncio.Future) or
                  asyncio.iscoroutine(obj) or
                  hasattr(obj, '__await__'))
    else:
        raise Exception(
            'isawaitable is not supported on Python {}'.format(
                sys.version_info))
    return result
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号