flags2_asyncio_executor.py 文件源码

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

项目:Books_SourceCode 作者: activeion 项目源码 文件源码
def download_one(cc, base_url, semaphore, verbose):
    try:
        with (yield from semaphore):
            image = yield from get_flag(base_url, cc)
    except web.HTTPNotFound:
        status = HTTPStatus.not_found
        msg = 'not found'
    except Exception as exc:
        raise FetchError(cc) from exc
    else:
        loop = asyncio.get_event_loop()  # <1>
        loop.run_in_executor(None,  # <2>
                save_flag, image, cc.lower() + '.gif')  # <3>
        status = HTTPStatus.ok
        msg = 'OK'

    if verbose and msg:
        print(cc, msg)

    return Result(status, cc)
# END FLAGS2_ASYNCIO_EXECUTOR
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号