diff --git a/streamrip/client/deezer.py b/streamrip/client/deezer.py index 056463f9..a9c28ed8 100644 --- a/streamrip/client/deezer.py +++ b/streamrip/client/deezer.py @@ -4,6 +4,7 @@ import logging import deezer +import requests from Cryptodome.Cipher import AES from ..config import Config @@ -40,6 +41,21 @@ def __init__(self, config: Config): self.logged_in = False self.config = config.session.deezer + # Increase the deezer-py requests session pool well above max_connections. + # Each concurrent download spawns several API calls (metadata, track token, + # GW info…) via asyncio.to_thread(), so the actual number of simultaneous + # requests easily exceeds max_connections. pool_maxsize is just a ceiling — + # no memory is pre-allocated — so a generous value avoids the urllib3 + # "Connection pool is full" warning without any real cost. + max_conn = config.session.downloads.max_connections + adapter = requests.adapters.HTTPAdapter( + pool_connections=max_conn, + pool_maxsize=max(max_conn * 4, 32), + max_retries=0, + ) + self.client.session.mount("https://", adapter) + self.client.session.mount("http://", adapter) + async def login(self): # Used for track downloads self.session = await self.get_session(