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)
评论列表
文章目录