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

Method release

redis/asyncio/connection.py:1646–1671  ·  view source on GitHub ↗

Releases the connection back to the pool

(self, connection: AbstractConnection)

Source from the content-addressed store, hash-verified

1644 raise ConnectionError("Connection not ready") from None
1645
1646 async def release(self, connection: AbstractConnection):
1647 """Releases the connection back to the pool"""
1648 # Connections should always be returned to the correct pool,
1649 # not doing so is an error that will cause an exception here.
1650 self._in_use_connections.remove(connection)
1651
1652 if connection.should_reconnect():
1653 await connection.disconnect()
1654
1655 self._available_connections.append(connection)
1656 await self._event_dispatcher.dispatch_async(
1657 AsyncAfterConnectionReleasedEvent(connection)
1658 )
1659
1660 # Record state transition: USED -> IDLE
1661 pool_name = get_pool_name(self)
1662 await record_connection_count(
1663 pool_name=pool_name,
1664 connection_state=ConnectionState.USED,
1665 counter=-1,
1666 )
1667 await record_connection_count(
1668 pool_name=pool_name,
1669 connection_state=ConnectionState.IDLE,
1670 counter=1,
1671 )
1672
1673 async def disconnect(self, inuse_connections: bool = True):
1674 """

Callers 2

get_connectionMethod · 0.95
releaseMethod · 0.45

Calls 8

record_connection_countFunction · 0.90
get_pool_nameFunction · 0.85
removeMethod · 0.80
should_reconnectMethod · 0.45
disconnectMethod · 0.45
appendMethod · 0.45
dispatch_asyncMethod · 0.45

Tested by

no test coverage detected