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

Method get_connection

redis/asyncio/cluster.py:3274–3288  ·  view source on GitHub ↗
(
        self, command_name: Optional[str] = None, *keys: Any, **options: Any
    )

Source from the content-addressed store, hash-verified

3272 return self._node.get_encoder()
3273
3274 async def get_connection(
3275 self, command_name: Optional[str] = None, *keys: Any, **options: Any
3276 ) -> AbstractConnection:
3277 connection = self._node.acquire_connection()
3278 try:
3279 await connection.connect()
3280 except BaseException:
3281 # connect() may fail mid-handshake (e.g. after the TCP socket
3282 # is established but before AUTH/HELLO completes) leaving the
3283 # connection in a partially-connected state. Disconnect before
3284 # returning it to the node's free queue so it is not reused.
3285 await connection.disconnect()
3286 self._node.release(connection)
3287 raise
3288 return connection
3289
3290 async def release(self, connection: AbstractConnection) -> None:
3291 # PubSub.aclose() disconnects the connection before calling

Callers

nothing calls this directly

Calls 4

acquire_connectionMethod · 0.80
connectMethod · 0.45
disconnectMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected