Skip to content

Commit

Permalink
[1.26] Mention pool size when discarding connections (#2497)
Browse files Browse the repository at this point in the history
  • Loading branch information
Streadz committed Dec 7, 2021
1 parent 80531c0 commit 06406c5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/urllib3/connectionpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,11 @@ def _put_conn(self, conn):
pass
except queue.Full:
# This should never happen if self.block == True
log.warning("Connection pool is full, discarding connection: %s", self.host)

log.warning(
"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.
if conn:
conn.close()
Expand Down
4 changes: 3 additions & 1 deletion test/test_connectionpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def test_max_connections(self):

assert pool.num_connections == 1

def test_pool_edgecases(self):
def test_pool_edgecases(self, caplog):
with HTTPConnectionPool(host="localhost", maxsize=1, block=False) as pool:
conn1 = pool._get_conn()
conn2 = pool._get_conn() # New because block=False
Expand All @@ -237,6 +237,8 @@ def test_pool_edgecases(self):
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_exception_str(self):
assert (
Expand Down

0 comments on commit 06406c5

Please sign in to comment.