requests-unixsocket icon indicating copy to clipboard operation
requests-unixsocket copied to clipboard

fix: Support pool_maxsize parameter for concurrent connections

Open kitaekatt opened this issue 1 month ago • 4 comments

Summary

UnixHTTPConnectionPool was not passing maxsize to the parent HTTPConnectionPool, causing it to always use the default of 1. This resulted in noisy "Connection pool is full, discarding connection" warnings when making concurrent requests through a Unix socket.

Changes

  • UnixHTTPConnectionPool now accepts maxsize parameter and passes it to parent class
  • UnixAdapter now accepts pool_maxsize parameter (default 1 for backwards compatibility) and passes it to UnixHTTPConnectionPool

Usage

This allows users to configure larger connection pools for concurrent request scenarios:

adapter = UnixAdapter(pool_maxsize=10)
session.mount('http+unix://', adapter)

Backwards Compatibility

Default value of pool_maxsize=1 preserves existing behavior. Only users who explicitly set a larger pool size will see different behavior.

kitaekatt avatar Dec 04 '25 21:12 kitaekatt

Looks good to me, and thanks for the great commit message and PR!

mupuf avatar Dec 05 '25 06:12 mupuf

_new_conn() creates individual connections, not pools. maxsize is a pool-level setting passed to HTTPConnectionPool.init(). The parent _new_conn() signature is just (self) with no pool config parameters.

kitaekatt avatar Dec 06 '25 16:12 kitaekatt

Ah, right. Could you add a test for the change?

webknjaz avatar Dec 07 '25 13:12 webknjaz

_new_conn()

Looking into urllib3's source, I'd say we should stop redefining its private method and set the ConnectionCls class attribute instead.

This is out of the scope here but I'd still block merging on having at least some regression test coverage.

webknjaz avatar Dec 14 '25 16:12 webknjaz