MCPcopy
hub / github.com/redis/redis-py / get_connection_count

Method get_connection_count

redis/connection.py:3341–3359  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3339 pass
3340
3341 def get_connection_count(self) -> List[tuple[int, dict]]:
3342 from redis.observability.attributes import get_pool_name
3343
3344 attributes = AttributeBuilder.build_base_attributes()
3345 attributes[DB_CLIENT_CONNECTION_POOL_NAME] = get_pool_name(self)
3346 free_connections_attributes = attributes.copy()
3347 in_use_connections_attributes = attributes.copy()
3348
3349 free_connections_attributes[DB_CLIENT_CONNECTION_STATE] = (
3350 ConnectionState.IDLE.value
3351 )
3352 in_use_connections_attributes[DB_CLIENT_CONNECTION_STATE] = (
3353 ConnectionState.USED.value
3354 )
3355
3356 return [
3357 (len(self._get_free_connections()), free_connections_attributes),
3358 (len(self._get_in_use_connections()), in_use_connections_attributes),
3359 ]
3360
3361
3362class BlockingConnectionPool(ConnectionPool):

Calls 5

_get_free_connectionsMethod · 0.95
get_pool_nameFunction · 0.90
build_base_attributesMethod · 0.80
copyMethod · 0.80