``requests_queued`` Number of requests queued because a connection wasn't
immediately available in the pool
``requests_wait_ms`` Total time in the queue for the clients waiting
- ``requests_timeouts`` Number of waiting clients whose request timed out
+ ``requests_errors`` Number of connection requests resulting in an error
+ (timeouts, queue full...)
``returns_bad`` Number of connections returned to the pool in a bad
state
``connections_num`` Number of connection attempts made by the pool to the
self._nconns_min = len(self._pool)
else:
if self.max_waiting and len(self._waiting) >= self.max_waiting:
+ self._stats[self._REQUESTS_ERRORS] += 1
raise TooManyRequests(
f"the pool {self.name!r} has aleady"
f" {len(self._waiting)} requests waiting"
try:
conn = await pos.wait(timeout=timeout)
except Exception:
- self._stats[self._REQUESTS_TIMEOUTS] += 1
+ self._stats[self._REQUESTS_ERRORS] += 1
raise
finally:
t1 = monotonic()
_REQUESTS_NUM = "requests_num"
_REQUESTS_QUEUED = "requests_queued"
_REQUESTS_WAIT_MS = "requests_wait_ms"
- _REQUESTS_TIMEOUTS = "requests_timeouts"
+ _REQUESTS_ERRORS = "requests_errors"
_USAGE_MS = "usage_ms"
_RETURNS_BAD = "returns_bad"
_CONNECTIONS_NUM = "connections_num"
self._nconns_min = len(self._pool)
else:
if self.max_waiting and len(self._waiting) >= self.max_waiting:
+ self._stats[self._REQUESTS_ERRORS] += 1
raise TooManyRequests(
f"the pool {self.name!r} has aleady"
f" {len(self._waiting)} requests waiting"
try:
conn = pos.wait(timeout=timeout)
except Exception:
- self._stats[self._REQUESTS_TIMEOUTS] += 1
+ self._stats[self._REQUESTS_ERRORS] += 1
raise
finally:
t1 = monotonic()
assert isinstance(errors[0], pool.TooManyRequests)
assert p.name in str(errors[0])
assert str(p.max_waiting) in str(errors[0])
+ assert p.get_stats()["requests_errors"] == 1
@pytest.mark.slow
assert stats["requests_num"] == 7
assert stats["requests_queued"] == 4
assert 850 <= stats["requests_wait_ms"] <= 950
- assert stats["requests_timeouts"] == 1
+ assert stats["requests_errors"] == 1
assert 1150 <= stats["usage_ms"] <= 1250
assert stats.get("returns_bad", 0) == 0
assert isinstance(errors[0], pool.TooManyRequests)
assert p.name in str(errors[0])
assert str(p.max_waiting) in str(errors[0])
+ assert p.get_stats()["requests_errors"] == 1
@pytest.mark.slow
assert stats["requests_num"] == 7
assert stats["requests_queued"] == 4
assert 850 <= stats["requests_wait_ms"] <= 950
- assert stats["requests_timeouts"] == 1
+ assert stats["requests_errors"] == 1
assert 1150 <= stats["usage_ms"] <= 1250
assert stats.get("returns_bad", 0) == 0