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

Method aclose

redis/asyncio/client.py:1053–1074  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1051 self.connection.deregister_connect_callback(self.on_connect)
1052
1053 async def aclose(self):
1054 # In case a connection property does not yet exist
1055 # (due to a crash earlier in the Redis() constructor), return
1056 # immediately as there is nothing to clean-up.
1057 if not hasattr(self, "connection"):
1058 return
1059 async with self._lock:
1060 if self.connection:
1061 # Use nowait=True to avoid awaiting StreamWriter.wait_closed(),
1062 # which can deadlock when a concurrent reader task (e.g. one
1063 # running pubsub.run() or get_message(block=True)) still holds
1064 # the transport. See https://github.com/redis/redis-py/issues/3941
1065 await self.connection.disconnect(nowait=True)
1066 self.connection.deregister_connect_callback(self.on_connect)
1067 await self.connection_pool.release(self.connection)
1068 self.connection = None
1069 self.channels = {}
1070 self.pending_unsubscribe_channels = set()
1071 self.patterns = {}
1072 self.pending_unsubscribe_patterns = set()
1073 self.shard_channels = {}
1074 self.pending_unsubscribe_shard_channels = set()
1075
1076 @deprecated_function(version="5.0.1", reason="Use aclose() instead", name="close")
1077 async def close(self) -> None:

Callers 3

__aexit__Method · 0.95
closeMethod · 0.95
resetMethod · 0.95

Calls 3

disconnectMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected