aiodownload.py 文件源码

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

项目:aiodownload 作者: jelloslinger 项目源码 文件源码
def __init__(self, client=None, download_strategy=None, request_strategy=None):

        if not client:
            # Get the event loop and initialize a client session if not provided
            self.loop = asyncio.get_event_loop()
            self.client = aiohttp.ClientSession(loop=self.loop)
        else:
            # Or grab the event loop from the client session
            self.loop = client._loop
            self.client = client

        # Configuration objects managing download and request strategies
        self._download_strategy = download_strategy or DownloadStrategy()  # chunk_size, home, skip_cached
        self._request_strategy = request_strategy or Lenient()  # concurrent, max_attempts, timeout

        # Bounded semaphore guards how many requests can run concurrently
        self._main_semaphore = asyncio.BoundedSemaphore(self._request_strategy.concurrent)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号