Mention pool size when discarding connections
MODIFY
src/urllib3/connectionpool.py
src/urllib3/connectionpool.py
@@ -318,7 +318,9 @@ class HTTPConnectionPool(ConnectionPool, RequestMethods):
) from None
log.warning(
- "Connection pool is full, discarding connection: %s", self.host
+ "Connection pool is full, discarding connection: %s. Connection pool size: %s",
+ self.host,
+ self.pool.qsize(),
)
# Connection never got put back into the pool, close it.

MODIFY
test/test_connectionpool.py
test/test_connectionpool.py
@@ -225,7 +225,9 @@ class TestConnectionPool:
assert pool.num_connections == 1
- def test_put_conn_when_pool_is_full_nonblocking(self) -> None:
+ def test_put_conn_when_pool_is_full_nonblocking(
+ self, caplog: pytest.LogCaptureFixture
+ ) -> None:
"""
If maxsize = n and we _put_conn n + 1 conns, the n + 1th conn will
get closed and will not get added to the pool.
@@ -248,6 +250,8 @@ class TestConnectionPool:
assert conn2 != pool._get_conn()
assert pool.num_connections == 3
+ assert "Connection pool is full, discarding connection" in caplog.text
+ assert "Connection pool size: 1" in caplog.text
def test_put_conn_when_pool_is_full_blocking(self) -> None:
"""

Mention pool size when discarding connections (#2470)