async.py 文件源码

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

项目:PyS60-Projects 作者: gauravssnl 项目源码 文件源码
def map(requests, prefetch=True, size=None):
    """Concurrently converts a list of Requests to Responses.

    :param requests: a collection of Request objects.
    :param prefetch: If False, the content will not be downloaded immediately.
    :param size: Specifies the number of requests to make at a time. If None, no throttling occurs.
    """

    requests = list(requests)

    pool = Pool(size) if size else None
    jobs = [send(r, pool) for r in requests]
    gevent.joinall(jobs)

    if prefetch:
        [r.response.content for r in requests]

    return [r.response for r in requests]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号