Skip to content

fix(deezer): silence connection pool warnings by sizing the requests adapter correctly#997

Open
berettavexee wants to merge 2 commits into
nathom:devfrom
berettavexee:fix/deezer-connection-pool
Open

fix(deezer): silence connection pool warnings by sizing the requests adapter correctly#997
berettavexee wants to merge 2 commits into
nathom:devfrom
berettavexee:fix/deezer-connection-pool

Conversation

@berettavexee

@berettavexee berettavexee commented Jun 14, 2026

Copy link
Copy Markdown

Problem

When downloading albums or playlists concurrently, urllib3 logs repeated warnings:

WARNING  Connection pool is full, discarding connection: api.deezer.com. Connection pool size: 10

The deezer-py library uses a requests.Session with the default HTTPAdapter, whose pool_maxsize is 10. Streamrip calls deezer-py from multiple asyncio.to_thread() coroutines running in parallel — one per track being resolved — so the number of simultaneous HTTP connections to api.deezer.com easily exceeds the pool ceiling. urllib3 then discards the excess connections and logs a warning for each one.

Fix

Mount a custom HTTPAdapter on the deezer-py session with a pool_maxsize large enough to absorb concurrent API calls:

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)

pool_maxsize is just a ceiling — urllib3 does not pre-allocate connections — so using max(max_connections × 4, 32) has no memory cost and ensures the pool is never exhausted under typical usage.

Idea from hank-bond/streamrip.

Test plan

  • Download an album or playlist with concurrency = true → no connection pool warnings
  • Works with default max_connections = 10 and with lower values (e.g. 3)

🤖 Generated with Claude Code

berettavexee and others added 2 commits June 14, 2026 23:53
The deezer-py library uses a requests.Session with the default urllib3
pool size (10). When concurrent downloads exceed that limit, urllib3
logs a noisy warning for every discarded connection:
  "Connection pool is full, discarding connection: api.deezer.com"

Instead of silencing the warning with setLevel(ERROR), configure the
HTTPAdapter pool sizes to match config.session.downloads.max_connections
so the pool is never exhausted and no connections are discarded.

Idea from https://github.com/hank-bond/streamrip

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…verflow

max_connections controls download concurrency, but each download spawns
several concurrent API calls (metadata, track token, GW info) via
asyncio.to_thread(). The number of simultaneous requests.Session calls
easily exceeds max_connections, causing urllib3 to discard connections
and log warnings.

Use max(max_connections * 4, 32) as pool_maxsize — a generous ceiling
with no memory cost — so the pool is never exhausted.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant